http://stackoverflow.com/questions/3748568/how-can-i-launch-androids-email-activity-with-an-attachment-attached-in-the-emai

http://stackoverflow.com/questions/2264622/android-multiple-email-attachment-using-intent-question

http://blog.blackmoonit.com/2010/02/filebrowser-send-receive-intents.html


public static void email(Context context, String emailTo, String emailCC,
   
String subject, String emailText, List<String> filePaths)
{
   
//need to "send multiple" to get more than one attachment
   
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
    emailIntent
.setType("plain/text");
    emailIntent
.putExtra(android.content.Intent.EXTRA_EMAIL,
       
new String[]{emailTo});
    emailIntent
.putExtra(android.content.Intent.EXTRA_CC,
       
new String[]{emailCC});
   
//has to be an ArrayList
   
ArrayList<Uri> uris = new ArrayList<Uri>();
   
//convert from paths to Android friendly Parcelable Uri's
   
for (String file : filePaths)
   
{
       
File fileIn = new File(file);
       
Uri u = Uri.fromFile(fileIn);
        uris
.add(u);
   
}
    emailIntent
.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
    context
.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
}
Intent intent = new Intent(Intent.ACTION_SEND);
intent
.setType("text/html");
intent
.putExtra(Intent.EXTRA_EMAIL, new String[]{"to@example.com"});
intent
.putExtra(Intent.EXTRA_SUBJECT, "the subject");
intent
.putExtra(Intent.EXTRA_TEXT, Html.fromHtml("the content"));
intent
.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/file.ext"));
startActivity
(intent);

+ Recent posts