How do I launch the email app with the "to" field pre-filled?

android, android-activity, android-intent, email

Solution

Try this snippet by dylan:

/* Create the Intent */
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);

/* Fill it with Data */
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"to@email.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Text");

/* Send it off to the Activity-Chooser */
context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));

Key pieces: using `EXTRA_EMAIL` for your addresses and using `createChooser()` in case the user has more than one email client configured.

Problem

I tried this code which I found here: ``` Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "testemail@gmail.com", null)); startActivity(intent); ``` But I get a message on the screen which reads "Unsupported Action". Any ideas of how to get this working?

Original source