By using following code, i am trying to attach multiple files to an E-Mail, but not getting attachments when using ArrayList
.
public void sendImage() {
// TODO Auto-generated method stub
Intent i = new Intent(Intent.ACTION_SEND_MULTIPLE);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setType("message/rfc822");
i.setClassName("com.google.android.gm",
"com.google.android.gm.ComposeActivityGmail");
i.putExtra(Intent.EXTRA_EMAIL, new String[] { "test@domain.tld" });
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT, "body of email");
ArrayList<Uri> uris = new ArrayList<Uri>();
String[] filePaths = new String[] {
"file:///sdcard/Custom/CapturedVideo.mp4",
"file:///sdcard/Custom/CapturedImage.jpg" };
for (String file : filePaths) {
File fileIn = new File(file);
Uri u = Uri.fromFile(fileIn);
uris.add(u);
}
i.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
startActivity(i);
}
Note:- Earlier i was attaching single file to an EMail ! successfully !
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/Custom/CapturedImage.jpg"));