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(); | |
} | |
}); |
Let me Google that for you, and click "I'm feeling lucky": "android recipient EXTRA_EMAIL not working"
http://stackoverflow.com/questions/9097080/intent-extra-email-not-populating-the-to-field
"EXTRA_EMAIL" requires an array. Not a single string.
Thanks. I'll give it a shot.
## Brian Jackson
Sent from my Android phone. Please excuse my brevity.
…On Apr 18, 2012 10:24 AM, "Dawson Toth" < ***@***.***> wrote:
Let me Google that for you, and click "I'm feeling lucky": "android
recipient EXTRA_EMAIL not working"
http://stackoverflow.com/questions/9097080/intent-extra-email-not-populating-the-to-field
"EXTRA_EMAIL" requires an array. Not a single string.
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/832158
Unfortunately that didn't work either under Appcelerator
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, ["[email protected]"]);
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
Dawson,
How would you populate the recipient and CC fields? I tried intent.putExtra(Ti.Android.EXTRA_EMAIL,'[email protected]'), but it's not working.