I am using Intent .ACTION_SEND
to get default email client. It works fine but now i need to attach more than one file to email.
email.putExtra(android.content.Intent.EXTRA_STREAM,...)
attaches only last uri added to it.
So can I attach multiple files? I think this can be done by using Intent.ACTION_SEND_MULTIPLE
. Here is the code I am trying:
String uri=getScreenShot(); Intent email = new Intent(android.content.Intent.ACTION_SEND); email.setType("application/octet-stream"); email.putExtra(Intent.EXTRA_STREAM, Uri.parse(uri)); email.putExtra(android.content.Intent.EXTRA_STREAM, Uri.parse("file:"+csvpath)); alert.dismiss(); ctx.startActivity(Intent.createChooser(email, "Send mail..."));
Thanks in advance.
Select all of the files that you wish to send via email and copy them to a new folder. Now, right click on the folder and then select Send to. Selecting this will give you multiple options, look for the one that says Compressed (zipped) folder. Select this option and it will convert your folder into a zipped file.
When you open the folder where the files are stored, select one and then press and hold the Ctrl Key down while you click each file you want to attach. When you are finished click the Open Button and all of the selected files will be attached.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With