I want to attach file in a mail....The thing is I want to use ACTION_SENDTO
.When I send the mail without an attachment it works fine but when I try to attach a file it gives an exception (android.content.ActivityNotFoundException
) just like the following link:
How to launch email intent with an attached image
I tried what the answer in that said but didn't get it fixed. Here's my code
Uri mail= Uri.fromParts("mailto",message, null);
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, mail);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, sub);
emailIntent.putExtra(Intent.EXTRA_TEXT, mailcontent);
emailIntent.setData(Uri.parse("file://" + Environment.getExternalStorageDirectory()+"/ab.jpg"));
emailIntent.setType("image/jpg");
startActivity(emailIntent);