以编程方式发送电子邮件

时间:2012-07-03 05:01:21

标签: android email

  

可能重复:
  Android: How do I attach a temporary, generated image to an email?

我正在尝试以编程方式将图片作为电子邮件附件发送,电子邮件是从我这边发送的,但不会转到我的电子邮件收件箱。

1 个答案:

答案 0 :(得分:1)

只需尝试一下 -

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[]{"email"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,"Test");
//has to be an ArrayList
ArrayList<Uri> uris = new ArrayList<Uri>();
//convert from paths to Android friendly Parcelable Uri's
for (String file : filePaths)
{
    File fileIn = new File(file);
    Uri u = Uri.fromFile(fileIn);
    uris.add(u);
}
emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
context.startActivity(emailIntent);

Have a look at this answer希望这有助于你