Android电子邮件附件丢失

时间:2015-06-05 18:14:24

标签: android email android-intent email-attachments

我正在尝试发送带有图片作为附件的电子邮件。我在发送时看到附加到邮件的项目,但是在收件箱中我只看到邮件但附件丢失。如果我的代码在某处出错,请帮帮我

    ArrayList<String> fetchList= new ArrayList<>();
    fetchList= getIntent().getStringArrayListExtra("Uri");
    ArrayList<Uri> uriList=new ArrayList<>();
    for (int i=0;i<fetchList.size();i++){
        uriList.add(i,Uri.parse(fetchList.get(i)));
    }

    public void sendClicked(View view) {
    String emailBody =textMessage.getText().toString();
    String emailSubject=textSubject.getText().toString();
    String Email_To[]=new String[]{"kittutanu@yahoo.co.in"};

    final Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    intent.setType("text/plain"); 
    intent.putExtra(Intent.EXTRA_EMAIL, Email_To);
    intent.putExtra(Intent.EXTRA_SUBJECT, emailSubject);
    intent.putExtra(Intent.EXTRA_TEXT, emailBody);
    if (uriList != null) {
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uriList);
    }
    try {
        this.startActivity(intent);
    } catch (android.content.ActivityNotFoundException ex) {
        Toast.makeText(this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
    }
}

}

1 个答案:

答案 0 :(得分:0)

您是否尝试过使用multipart / alternative或multipart / mixed类型?

以下是How to send an email with a file attachment in Android

的示例