i am trying to programmatically attach an image to an email body from my app .I’ve seen some topics about how to do that and put my code exactly the same way but it’s useless i don’t get the image in the other side (from this post ) .
for more information here is my code:
Intent emailIntent=new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.setType("image/jpg");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.mail_partage_objet));
emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(readEmailTemplate()));
String imageFilePath=Constants.PHOTO_CACHE_PATH+"/"+currentPlace.getPhotoFileName();
Log.d(TAG,"Picture Path: "+imageFilePath);
emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(imageFilePath));
startActivity(Intent.createChooser(emailIntent, getResources().getString(R.string.email_share)));
where PHOTO_CACHE_PATH is the path of directory where the image is saved and it’s on SDcard
I think you forgot:
emailIntent.setType("application/octet-stream");.Example for multiattachments:
Hope it helps,
Toni