Skip to content

Instantly share code, notes, and snippets.

@JafarKhQ
Created November 28, 2012 12:31
Show Gist options
  • Save JafarKhQ/4160927 to your computer and use it in GitHub Desktop.
Save JafarKhQ/4160927 to your computer and use it in GitHub Desktop.
Send Email Intent
Intent sendEmailIntent = new Intent(Intent.ACTION_SEND);
sendEmailIntent.setType("plain/text"); // "plain/text" != "text/plain"
sendEmailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "subject");
sendEmailIntent.putExtra(Intent.EXTRA_TEXT, "body");
sendEmailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[] { "[email protected]" });
// startActivity(sendEmailIntent); OR
startActivity(Intent.createChooser(sendEmailIntent, "send using…"));
Intent sendEmailIntent = new Intent(Intent.ACTION_SENDTO);
String uriText = "mailto:[email protected]" +
"?subject=the subject" +
"&body=the body";
uriText = uriText.replace(" ", "%20");
Uri uri = Uri.parse(uriText);
sendEmailIntent.setData(uri);
startActivity(sendEmailIntent);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment