发送Email的多种方式(多收件人,附件)

Uri uri = Uri.parse("mailto:xxx@abc.com");

Intent it = new Intent(Intent.ACTION_SENDTO, uri);

startActivity(it);

 

带附件的:

Intent intent = new Intent(Intent.ACTION_SEND);   

intent.putExtra(Intent.EXTRA_EMAIL, address);   

intent.putExtra(Intent.EXTRA_SUBJECT, filename);   

intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + filename)); ;

intent.setType("text/csv");   

startActivity(Intent.createChooser(intent, "EMail File"));  

 

或者:

Intent it = new Intent(Intent.ACTION_SEND);  

it.putExtra(Intent.EXTRA_EMAIL, "me@abc.com");  

it.putExtra(Intent.EXTRA_TEXT, "The email body text");  

it.setType("text/plain");  

startActivity(Intent.createChooser(it, "Choose Email Client"));

 

多收件人:

Intent it=new Intent(Intent.ACTION_SEND);    

String[] tos={"me@abc.com"};    

String[] ccs={"you@abc.com"};    

it.putExtra(Intent.EXTRA_EMAIL, tos);    

it.putExtra(Intent.EXTRA_CC, ccs);    

it.putExtra(Intent.EXTRA_TEXT, "The email body text");    

it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");     

it.setType("message/rfc822");    

startActivity(Intent.createChooser(it, "Choose Email Client"));  

 

带MP3附件:

Intent it = new Intent(Intent.ACTION_SEND);  

it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");  

it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");  

sendIntent.setType("audio/mp3");  

startActivity(Intent.createChooser(it, "Choose Email Client"));

posted @ 2011-11-24 16:31  Glan  阅读(267)  评论(0)    收藏  举报