Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to attach mutiple images from the SD-card to email?

Tags:

android

How to send multiple image in an email? I would greatly prefer the image to be in the body of the email, as opposed to attaching it.

I have run this code but doesn't work.

like image 921
Akash Singh Avatar asked Jan 29 '26 05:01

Akash Singh


1 Answers

Where image_path Array list use for store image path address's for SD card

image_path.add(Environment.getExternalStorageDirectory() + "/defaultg1.jpg");
image_path.add(Environment.getExternalStorageDirectory() + "/defaultg2.jpg");

if(image_path.size() > 0 && edt_weight1.getText().length() > 0 && edt_weight2.getText().length() > 0){
            ArrayList<Uri> uris = new ArrayList<Uri>();
            for(int i=0;i<image_path.size();i++){

                   File fileIn = new File(image_path.get(i));
                       Uri u = Uri.fromFile(fileIn);
                       uris.add(u);
                }

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
    emailIntent.setType("image/jpg");
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Enjoy the photo");
    emailIntent.putExtra(Intent.EXTRA_TEXT, "Plz find the attachment.");
    emailIntent.putExtra(Intent.EXTRA_STREAM, uris);
    startActivity(Intent.createChooser(emailIntent, "Email:"));

Enjoy the code...

like image 158
Akash Singh Avatar answered Jan 30 '26 21:01

Akash Singh