there is an intent for “send an email.” In our application needs to send mail, how can invoke that intent
+2
A:
You can't send an email directly without using a hacked version of the javamail apis, but you can easily have the user send one for you using Intent.ACTION_SEND and an Intent Chooser.
final Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "my subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "body text");
context.startActivity(Intent.createChooser(intent, "Send mail...));
Make sure you're on an actual device when you test this code as it won't work from within the emulator.
Mike
2009-11-26 06:52:08
Note that there's a typo -- it's text/plain, not plain/text. The typo came from the AndroidSnippets.org snippet that I've used in various blog posts and SO answers.
CommonsWare
2009-11-26 11:03:58
Good catch, thank you commonsware. Fixed.
Mike
2009-11-26 17:17:55