android - send mail

Posted by 겨울에
2011. 2. 4. 01:10 scrap/ Android
출처 : http://blog.naver.com/lowmans?Redirect=Log&logNo=100117691716

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);




'scrap >  Android' 카테고리의 다른 글

OutOfMemoryError  (0) 2011.02.04
Android tip 100  (1) 2011.02.04
ListView  (0) 2011.02.04
Activity를 refresh 할 수 있나요?  (0) 2011.02.04
Android File List  (0) 2011.02.04