简体   繁体   English

如何通过Android中的Intent发送邮件?

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

I would like to send an email with an Intent. 我想发一封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. 我想以编程方式打开一个对话框,显示处理此Intent的不同程序,并让用户显示他最喜欢的邮件程序。 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 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"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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