Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6134707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:23:22+00:00 2026-05-23T17:23:22+00:00

How to attach multiple files in email in android? Is there any permission required

  • 0

How to attach multiple files in email in android?
Is there any permission required for multiple files attachment to an intent?
I am trying with putParcelableArrayListExtra(Intent.EXTRA_STREAM, ArrayList uriList) method but still in doubt whether Uri class is <? extends Parcelable> or not. I am not able to attach any file to email.

This is my code ::

Intent sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
sendIntent.setType("plain/text");
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {"soubhabpathak2010@gmail.com"});
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Accident Capture");
sendIntent.putExtra(Intent.EXTRA_TEXT, emailBody);

ArrayList<Uri> uriList = getUriListForImages();
sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uriList);
Log.d(TAG, "Size of the ArrayList :: " +uriList.size());
FormHolderActivity.this.startActivity(Intent.createChooser(sendIntent, "Email:"));

and getUriListForImages() this method is defined as bellow —–


private ArrayList<Uri> getUriListForImages()  {

    ArrayList<Uri> uriList = new ArrayList<Uri>();
    String imageDirectoryPath =  Environment.getExternalStorageDirectory().getAbsolutePath()+ "/accident/";
    File imageDirectory = new File(imageDirectoryPath);
    String[] fileList = imageDirectory.list();

    if(fileList.length != 0) {
        for(int i=0; i<fileList.length; i++)
        {
            String file = "file://" + imageDirectoryPath + fileList[i];
            Log.d(TAG, "File name for Uri :: " + file);
            Uri uriFile = Uri.parse(file);
            uriList.add(uriFile);
            Log.d(TAG, "Image File for Uri :: " +(file));

        }
    }
    return uriList;
}

To, subject and body of the email is coming and I have images in the accident folder in sdcard (I am using 2.1 API level 7) but nothing is attaching even there is also no exception in logcat.Arraylist is also ok(means length OK and name of the files are ok too). Can anyone help me to solve this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:23:22+00:00Added an answer on May 23, 2026 at 5:23 pm

    After 1 day work finally I am able to attach multiple image files from \sdcard\accident\ folder to email client. For attaching multiple files I had to add the images to the ContentResolver which is responsible for gallery images provider.
    Here is the Complete Code —

    Intent sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    sendIntent.setType("plain/text");
    sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {"soubhabpathak2010@gmail.com"});
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Accident Capture");
    sendIntent.putExtra(Intent.EXTRA_TEXT, emailBody);
    
    ArrayList<Uri> uriList = getUriListForImages();
    sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uriList);
    Log.d(TAG, "Size of the ArrayList :: " +uriList.size());
    FormHolderActivity.this.startActivity(Intent.createChooser(sendIntent, "Email:"));
    

    So there is no change in the First Section of Code — But Change is in getUriListForImages() method which is as follows—

    
    
        private ArrayList<Uri> getUriListForImages() throws Exception {
                    ArrayList<Uri> myList = new ArrayList<Uri>();
                    String imageDirectoryPath = Environment.getExternalStorageDirectory().getAbsolutePath()+ "/accident/";
                    File imageDirectory = new File(imageDirectoryPath);
                    String[] fileList = imageDirectory.list();
                    if(fileList.length != 0) {
                        for(int i=0; i<fileList.length; i++)
                        {   
                            try 
                            {   
                                ContentValues values = new ContentValues(7);
                                values.put(Images.Media.TITLE, fileList[i]);
                                values.put(Images.Media.DISPLAY_NAME, fileList[i]);
                                values.put(Images.Media.DATE_TAKEN, new Date().getTime());
                                values.put(Images.Media.MIME_TYPE, "image/jpeg");
                                values.put(Images.ImageColumns.BUCKET_ID, imageDirectoryPath.hashCode());
                                values.put(Images.ImageColumns.BUCKET_DISPLAY_NAME, fileList[i]);
                                values.put("_data", imageDirectoryPath + fileList[i]);
                                ContentResolver contentResolver = getApplicationContext().getContentResolver();
                                Uri uri = contentResolver.insert(Images.Media.EXTERNAL_CONTENT_URI, values);
                                myList.add(uri);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                    return myList;
                } 
    
    

    This is working fine and I am able to attach multiple image files to emulator default email client and send them successfully .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to attach a PDF attachment to an email being sent with System.Net.Mail.
How to attach the multiple files in an email using c#. MailMessage mail =
How do I attach multiple files as e-mail attachments in vb.net? I am trying
Is it possible to attach multiple files to an email using the MessageUI (mfmailcomposeviewcontroller)?
I'm trying to attach a file to an outgoing email but the attachment size
I've attached multiple functions in multiple files to $(document).ready and would like to attach
Is it possible to attach multiple onClick listeners to buttons in android? Example: btn1.setOnClickListener(listener1);
In my application I want to attach multiple photos to an email in code,
I am trying to attach files in my RoR app. I am using Rails
I am trying to get Paperclip to attach multiple images, 4 in my case,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.