Android 调用系统email程序发邮件

//系统邮件系统的动作为android.content.Intent.ACTION_SEND
Intent email = new Intent(android.content.Intent.ACTION_SEND);
email.setType("plain/text");
emailReciver = new String[]{"zhouyongyang122@gmail.com", "421134693@qq.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, "请选择邮件发送软件"));

在android中还有许多发送Email的写法。

方法一:

Uri uri=Uri.parse(mailto:***@gmail.com);

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

startActivity(emailIntent);

方法二:

Intent emailIntent=new Intent(Intent.ACTION_SEND);

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

emailIntent.putExtra(Intent.EXTRA_CC,you@abc.com);

emialIntent.putExtra(Intent.EXTRA_TEXT,"the email body text");

emailIntent.putExtra(Intent.EXTRA_SUBJECT,"the email subject text");

emailIntent.setType("message/rfc822");

startActivity(Intent.createChooser(emailIntent,"your client"));

 

带附件:

Intent returnIt = new Intent(Intent.ACTION_SEND);

String[] tos = { "wangmeng@gmail.com" }; //send to someone

String[] ccs = { "tongyue@gmail.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);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值