使用意图发送带附件的电子邮件

时间:2014-08-14 08:50:29

标签: android email android-intent

我想将附有图片的邮件发送到同一地址。

2 个答案:

答案 0 :(得分:1)

使用下面的代码希望它能帮到你

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
emailIntent.setType("application/image");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{strEmail}); 
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Test Subject"); 
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "From My App"); 
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/Myimage.jpeg"));
startActivity(Intent.createChooser(emailIntent, "Send mail...")); 

答案 1 :(得分:0)

查看android开发培训以获取更多信息和示例Android Training

Intent emailIntent = new Intent(Intent.ACTION_SEND);
// The intent does not have a URI, so declare the "text/plain" MIME type
emailIntent.setType(HTTP.PLAIN_TEXT_TYPE);
emailIntent.putExtra(Intent.EXTRA_EMAIL,
new String[] {"jon@example.com"}); // recipients
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Email subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Email message text");
emailIntent.putExtra(Intent.EXTRA_STREAM, 
Uri.parse("content://path/to/emai/attachment"));
// You can also attach multiple items by passing an ArrayList of Uris
startActivity(emailIntent);