How to send emails from my Android application?

android, email

Solution

The best (and easiest) way is to use an `Intent`:

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"recipient@example.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT   , "body of email");
try {
    startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
    Toast.makeText(MyActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}

Otherwise you'll have to write your own client.

RFC822 is the standard for ARPA Internet Text Messages. See https://w3.org/Protocols/rfc822.

Problem

I am developing an application in Android. I don't know how to send an email from the application?

Original source

Related problems