how to attach multiple files to email client in android

Solution 1:

That works:

final Intent ei = new Intent(Intent.ACTION_SEND_MULTIPLE);
ei.setType("plain/text");
ei.putExtra(Intent.EXTRA_EMAIL, new String[] {"[email protected]"});
ei.putExtra(Intent.EXTRA_SUBJECT, "That one works");

then add files' uris:

ArrayList<Uri> uris = new ArrayList<Uri>();

ei.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
startActivityForResult(Intent.createChooser(ei, "Sending multiple attachment"), 12345);

Hope that helps.

Solution 2:

You can use putParcelableArrayListExtra method of Intent as shown below. Instead of using like this: email.putExtra(Intent.EXTRA_STREAM, Uri.parse(uri));, you can use an ArrayList as shown below:

ArrayList<Uri> uris = new ArrayList<Uri>();
//convert from paths to Android friendly Parcelable Uri's
for (String file : filePaths)
{
    File fileIn = new File(file);
    Uri u = Uri.fromFile(fileIn);
    uris.add(u);
}
email.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);