问题描述:

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 :"));

}

相关阅读:
Top