Issue
I tried this code which I found here:
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "[email protected]", null)); startActivity(intent);
But I get a message on the screen which reads "Unsupported Action". Any ideas of how to get this working?
Solution
/* Create the Intent */
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
/* Fill it with Data */
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Text");
/* Send it off to the Activity-Chooser */
context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
Key pieces: using EXTRA_EMAIL
for your addresses and using createChooser()
in case the user has more than one email client configured.
Answered By - CommonsWare
Answer Checked By - Marilyn (JavaFixing Volunteer)