简体   繁体   中英

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

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.

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM