Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to attach multiple files to email client in android

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.

like image 432
N-JOY Avatar asked Dec 29 '10 09:12

N-JOY


People also ask

How do I attach multiple files to an email?

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.

How do I attach multiple files?

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.


1 Answers

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.

like image 52
Herr K Avatar answered Sep 18 '22 09:09

Herr K