1

I've been trying since 2 hours, to find the code to email an image in Android. At least i was successful, but still have a problem. When i email the image, it opens as text file, and not as jpeg. I also used MIME type (image/jpeg), but in vain. Please help me with this.

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("image/jpg");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,e2.getText().toString());
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[]{e1.getText().toString()});
emailIntent.setType("image/jpg");
Uri path = Uri.parse("android.resource://com.mypackage.name/drawable/" + filename);
emailIntent.setType("image/jpg");
emailIntent.putExtra(Intent.EXTRA_STREAM, path);
emailIntent.setType("image/jpeg");
startActivity(Intent.createChooser(emailIntent, "Send Email"));

Any help will be appreciated.

Thank you!

nithinreddy
  • 6,167
  • 4
  • 38
  • 44
  • Well, atlast i was successful! I had to copy the image to sdcard, and then attach it to the mail! It worked fine now! – nithinreddy Jun 26 '11 at 09:34

1 Answers1

0

For those who need help, just copy the image to sdcard, and then attach! It works!

nithinreddy
  • 6,167
  • 4
  • 38
  • 44
  • Hey what if i wanted to attach image from resource or asset folder as i want to attach app logo with email and keeping logo in SD card may create some copying issue. Help if you have any way to solve this. – Ankit May 21 '12 at 07:12
  • Put it in a inner directory? Or an other alternative would be, after share is done, delete the image again? – nithinreddy May 21 '12 at 07:29