开发者

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 yo开发者_JS百科u 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"));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜