Android : how to open a mail composer view?

Rob picture Rob · Jul 11, 2012 · Viewed 9.4k times · Source

I just want to know how to open Mail Composer in Android.

With iOS, I would do something like this :

MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
[controller setSubject:@"Mail subject"];
[controller setMessageBody:@"Mail body" isHTML:bool];
[controller setToRecipients:recipientsList];
if(controller) [self presentModalViewController:controller animated:YES];

How about Android ?

Thanks a lot.

Answer

AkashG picture AkashG · Jul 11, 2012
Intent intent=new Intent(Intent.ACTION_SEND);
String[] recipients={"[email protected]"};
intent.putExtra(Intent.EXTRA_EMAIL, recipients);
intent.putExtra(Intent.EXTRA_SUBJECT,"abc");
intent.putExtra(Intent.EXTRA_TEXT,"def");
intent.putExtra(Intent.EXTRA_CC,"ghi");
intent.setType("text/html");
startActivity(Intent.createChooser(intent, "Send mail"));