Sending email with attachment programmatically in Android

If you want to send email with attachment in android application programmatically you can use below method for it.

String fileLocation="your attachment file path here like /mnt/sdcard/ ... ";
Intent emailIntent = new Intent(Intent.ACTION_SEND);
// set the type to 'email'
emailIntent .setType("");
// add email(s) here to whom you want to send email
String to[] = {""};
emailIntent .putExtra(Intent.EXTRA_EMAIL, to);
// add the attachment
emailIntent .putExtra(Intent.EXTRA_STREAM, fileLocation);
// add mail subject
emailIntent .putExtra(Intent.EXTRA_SUBJECT, "Mail Subject");
// create mail service chooser
startActivity(Intent.createChooser(emailIntent , "Send email..."));

Just modify parameters according to your use and you are ready to go.

(Visited 612 times, 1 visits today)