4

How does one send a simple email message, in code, on Android?

Jacob Marble
  • 26,540
  • 19
  • 67
  • 77
Sankar Ganesh PMP
  • 11,811
  • 11
  • 55
  • 89

3 Answers3

15
Intent sendIntent;

sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Test Subject");
sendIntent.putExtra(Intent.EXTRA_TEXT, "Test Text");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + fileName));
sendIntent.setType("image/jpeg");

startActivity(Intent.createChooser(sendIntent, "Send Mail"));
Jacob Marble
  • 26,540
  • 19
  • 67
  • 77
Sankar Ganesh PMP
  • 11,811
  • 11
  • 55
  • 89
4

Check out the code at anddev.org for how to do it using intents.

Chris Thompson
  • 34,318
  • 11
  • 78
  • 107
0

If you don't want to use the User interface for sending mails, check this link: Sending Email in Android using JavaMail API without using the default/built-in app

Community
  • 1
  • 1
Sonhja
  • 7,947
  • 16
  • 69
  • 124