Created
February 17, 2011 17:15
-
-
Save dawsontoth/832158 to your computer and use it in GitHub Desktop.
How to send emails in Appcelerator Titanium using activities and intents.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var win = Ti.UI.createWindow({ backgroundColor: '#fff' }); | |
var button = Ti.UI.createButton({ title: 'Share' }); | |
win.add(button); | |
win.open(); | |
button.addEventListener('click', function() { | |
var intent = Ti.Android.createIntent({ | |
action: Ti.Android.ACTION_SEND, | |
type: 'text/plain' | |
}); | |
intent.putExtra(Ti.Android.EXTRA_SUBJECT, 'My subject!'); | |
intent.putExtra(Ti.Android.EXTRA_TEXT, 'My text!'); | |
try { | |
Ti.Android.currentActivity.startActivity(intent); | |
} catch (ex) { | |
/* Handle Exception if no suitable apps installed */ | |
Ti.UI.createNotification({ message : 'No sharing apps installed!' }).show(); | |
} | |
}); |
Well that's excruciating. Mind creating a ticket so we can address whatever issue is preventing it from working? https://jira.appcelerator.org/secure/CreateIssue.jspa?pid=10190&issuetype=1&Create=Create
Tony Lukasavage confirmed it's a bug and submitted a ticket.
## Brian Jackson
Sent from my Android phone. Please excuse my brevity.
…On Apr 18, 2012 7:13 PM, "Dawson Toth" < ***@***.***> wrote:
Well that's excruciating. Mind creating a ticket so we can address
whatever issue is preventing it from working?
https://jira.appcelerator.org/secure/CreateIssue.jspa?pid=10190&issuetype=1&Create=Create
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/832158
This is the solution
var activity = Ti.Android.currentActivity;
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_SEND,
type: 'text/email'
});
intent.putExtra(Ti.Android.EXTRA_EMAIL, ["to@email.com"]);
intent.putExtra(Ti.Android.EXTRA_SUBJECT, "email subject");
intent.putExtra(Ti.Android.EXTRA_TEXT, "email body /message ");
activity.startActivity(intent, 'Email');
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unfortunately that didn't work either under Appcelerator