3

I have a bitmap that I have saved in the external storage. I already have a method that loads and returns the bitmap. My question is, how do I attach this image to an email Intent.

Note: I know how to start the email intent, I simply need to know how to attach the bitmap. Thanks.

This is how I am saving the pic:

private void savePicture(String filename, Bitmap b, Context ctx) {
    try {
        FileOutputStream out;
        out = ctx.openFileOutput(filename, Context.MODE_WORLD_READABLE);

        b.compress(Bitmap.CompressFormat.JPEG, 40, out);
        if (b.compress(Bitmap.CompressFormat.JPEG, 40, out) == true)
            out.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Kgrover
  • 2,106
  • 2
  • 36
  • 54

1 Answers1

3

try this for Attach Image with Email

Fetch Image From SdCard

String path = Environment.getExternalStorageDirectory().toString();     
File file = new File(path,"YourImageName.JPEG");
Uri pngUri = Uri.fromFile(file);

Email Intent

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_STREAM, pngUri);
Niranj Patel
  • 32,980
  • 10
  • 97
  • 133