简体   繁体   中英

How can I send a mail through an Intent in android?

I would like to send an email with an Intent.

I would like to programatically open up an dialog that shows the different programs that handle this Intent and lets the user show his favourite mail program. In the program I want to specify a Title, an receiver and a message body.

Could you give me an example on how to this?

Use the code below to send an email via an Intent:

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("plain/text");
intent.putExtra(Intent.EXTRA_EMAIL,new String[] { "address@example.com" });
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject of the mail");
intent.putExtra(Intent.EXTRA_TEXT, "body of the mail");

startActivity(Intent.createChooser(intent, "Title of the chooser dialog"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM