直接贴代码:
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
// 附件
File file = new File(Environment.getExternalStorageDirectory().getPath()+ File.separator + "simplenote"+ File.separator+"note.xml");
// 收件人
intent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] {"pop1030123@163.com"});
// 主题
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "note.xml");
// 正文
intent.putExtra(android.content.Intent.EXTRA_TEXT,"this is test extra.");
intent.setType("application/octet-stream");
//当无法确认发送类型的时候使用如下语句
//intent.setType(“*/*”);
//当没有附件,纯文本发送时使用如下语句
//intent.setType(“plain/text”);
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
NoteActivity.mNext_tab = NoteActivity.NOTE_SETTING;
startActivity(Intent.createChooser(intent, "Mail Chooser"));
另外的参考代码:
//系统邮件系统的动作为android.content.Intent.ACTION_SEND
Intent email = new Intent(android.content.Intent.ACTION_SEND);
email.setType("text/plain");
emailReciver = new String[]{"pop1030123@163.com", "fulon@163.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, "请选择邮件发送软件"));