首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

Android调用系统的发邮件步骤

2012-06-26 
Android调用系统的发邮件方法//系统邮件系统的动作为Android.content.Intent.ACTION_SENDIntent email n

Android调用系统的发邮件方法

//系统邮件系统的动作为Android.content.Intent.ACTION_SEND
Intent email = new Intent(Android.content.Intent.ACTION_SEND);
email.setType("plain/text");

/**

*email.setType("plain/text");

*纯文本传输
*email.setType("text/plain");
*流的形式传输

*/
emailReciver = new String[]{"www.linuxidc.com@www.linuxidc.com.com", "1234567@www.linuxidc.com.com"};


emailSubject = "你有一条短信";
emailBody = sb.toString();

?

//设置邮件默认地址
email.putExtra(Android.content.Intent.EXTRA_EMAIL, emailReciver);
//设置邮件默认标题
email.putExtra(Android.content.Intent.EXTRA_SUBJECT, emailSubject);
//设置要默认发送的内容
email.putExtra(Android.content.Intent.EXTRA_TEXT, emailBody);
//调用系统的邮件系统
startActivity(Intent.createChooser(email, "请选择邮件发送软件"));

带附件:


Intent returnIt = new Intent(Intent.ACTION_SEND);

?????? String[] tos = { "admin@www.linuxidc.com" }; //send to someone

?????? String[] ccs = { "root@www.linuxidc.com" };? //Carbon Copy to someone

?????? returnIt.putExtra(Intent.EXTRA_EMAIL, tos);

?????? returnIt.putExtra(Intent.EXTRA_CC, ccs);

?????? returnIt.putExtra(Intent.EXTRA_TEXT, "body");

?????? returnIt.putExtra(Intent.EXTRA_SUBJECT, "subject");

Uri uri = Uri.parse("file:///sdcard/mysong.MP3");

returnIt.putExtra(Intent.EXTRA_STREAM, uri);

returnIt.setType("audio/MP3");? //use this format no matter what your attachment type is

returnIt.setType("message/rfc882");

Intent.createChooser(returnIt, "Choose Email Client");

startActivity(returnIt);

?

热点排行