I am trying to send a PDF as an attachment with Android. Here is the code:
String[] mailto = {"me@gmail.com"};
Uri uri = Uri.parse("android.resource://com.mywebsite.sendemail/raw/mypdf");
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, mailto);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "My Subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "My Body");
emailIntent.setType("application/pdf");
emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(emailIntent, "Send email using:"));
Now this works, but the problem is that the attachment is called mypdf instead of mypdf.pdf. I can’t figure out how to send it using this extension ... This is what I need help with. Thank.
source
share