Cant Send Email With Multiple Attachment In Android Programmatically
I cant send email in android with multiple attachment using Intent chooser. After choosing gmail from chooser .It throws Unfortunately gmail has stopped error. I don't what mistake
Solution 1:
You can send multiple attachments over mail using the following code:
public boolean sendEmailWithMultipleAttachments(Context context,
String[] emailTo, String[] emailCC, String[] emailBCC,
String subject, String emailBody, List filePaths) throws ActivityNotFoundException {
final Intent emailIntent =
new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("message/rfc822");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, emailTo);
emailIntent.putExtra(android.content.Intent.EXTRA_CC, emailCC);
emailIntent.putExtra(android.content.Intent.EXTRA_BCC, emailBCC);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
ArrayList<String> extra_text = new ArrayList<String>();
extra_text.add("Your text here");
ei.putStringArrayListExtra(Intent.EXTRA_TEXT, extra_text);
if (filePaths != null) {
// has to be an ArrayList
ArrayList uris = new ArrayList();
// convert from paths to Android friendly Parcelable Uri's
for (String file : filePaths) {
File fileIn = new File(file);
if (fileIn.exists()) {
Uri u = Uri.fromFile(fileIn);
uris.add(u);
}
}
emailIntent.putParcelableArrayListExtra
(Intent.EXTRA_STREAM, uris);
}
context.startActivity(Intent.createChooser(emailIntent, "Sent mail"));
return true;
}
Solution 2:
I didn't change any code. But after running it today, its working perfectly. Don't know which one wrong or right. Anyway, now its working fine for me, the same code which i posted. Thank You Alok Nair for such a help.
Post a Comment for "Cant Send Email With Multiple Attachment In Android Programmatically"