当前位置: 动力学知识库 > 问答 > 编程问答 >

android - Send an attachment via mail

问题描述:

I cannot succeed in sending an attachment from my android application using mail services. The code I have is the following: However the attachment is not sent maybe because I use the wrong path. Can you help me?

 next1.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

String[] emails = {"[email protected]"};

String subject = "MRA Diagnosis";

String message = "Automatically sent by MRA Diagnosis Android Application";

Uri path = Uri.parse("file:///android_asset/MRA Diagnosis/assets/MRA Diagnosis.xls");

Intent email = new Intent(Intent.ACTION_SEND);

email.putExtra(Intent.EXTRA_EMAIL, emails);

email.putExtra(Intent.EXTRA_SUBJECT, subject);

email.putExtra(Intent.EXTRA_TEXT, message);

email.putExtra(Intent.EXTRA_STREAM, path);

// need this to prompts email client only

email.setType("message/rfc822");

startActivity(Intent.createChooser(email, "Choose an Email Application :"));

}

分享给朋友:
您可能感兴趣的文章:
随机阅读: