How to send email in Android ? [duplicate]

2019-01-07 22:37发布

问题:

This question already has an answer here:

  • How can I send emails from my Android application? 19 answers

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

回答1:

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"));


回答2:

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



回答3:

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



标签: android email