Last week, I shown you how to send an Email in Android thanks to JavaMail API by using GMail SMTP. This week, you’re going to learn how to send an Email in Android by using Intent and so applications installed on the Android OS.

Code snippet is very simple compared to solution using JavaMail API :


 String to = "To";
 String subject = "Subject";
 String message = "Message to send";

 Intent email = new Intent(Intent.ACTION_SEND);
 email.putExtra(Intent.EXTRA_EMAIL, new String[]{ to});
 //email.putExtra(Intent.EXTRA_CC, new String[]{ to});
 //email.putExtra(Intent.EXTRA_BCC, new String[]{to});
 email.putExtra(Intent.EXTRA_SUBJECT, subject);
 email.putExtra(Intent.EXTRA_TEXT, message);

 // This type is needed to prompt only email client chooser
 email.setType("message/rfc822");

 startActivity(Intent.createChooser(email, "Choose an Email client :"));

 

To see this code in action in a real application, you can go to Youtube and see the entire tutorial :