I am trying to send a pdf as an attachment from Android. Here is the code:
String[] mailto = {"[email protected]"};
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 cannot figure out how to send it with it's extension... That's what I need help with. Thanks.