android调用邮件应用发送email

 

直接贴代码:

Java代码  收藏代码
  1. Intent intent = new Intent(android.content.Intent.ACTION_SEND);  
  2.         // 附件  
  3.         File file = new File(Environment.getExternalStorageDirectory().getPath()+ File.separator + "simplenote"+ File.separator+"note.xml");  
  4.         // 收件人  
  5.         intent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] {"pop1030123@163.com"});  
  6.         // 主题  
  7.         intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "note.xml");  
  8.         // 正文  
  9.         intent.putExtra(android.content.Intent.EXTRA_TEXT,"this is test extra.");  
  10.         intent.setType("application/octet-stream");  
  11.         //当无法确认发送类型的时候使用如下语句  
  12.         //intent.setType(“*/*”);  
  13.         //当没有附件,纯文本发送时使用如下语句  
  14.         //intent.setType(“plain/text”);  
  15.         intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));  
  16.         NoteActivity.mNext_tab = NoteActivity.NOTE_SETTING;  
  17.         startActivity(Intent.createChooser(intent, "Mail Chooser"));  

另外的参考代码:

Java代码  收藏代码
  1. //系统邮件系统的动作为android.content.Intent.ACTION_SEND  
  2. Intent email = new Intent(android.content.Intent.ACTION_SEND);  
  3. email.setType("text/plain");  
  4. emailReciver = new String[]{"pop1030123@163.com", "fulon@163.com"};  
  5. emailSubject = "你有一条短信";  
  6. emailBody = sb.toString();  
  7.   
  8. //设置邮件默认地址  
  9. email.putExtra(android.content.Intent.EXTRA_EMAIL, emailReciver);  
  10. //设置邮件默认标题  
  11. email.putExtra(android.content.Intent.EXTRA_SUBJECT, emailSubject);  
  12. //设置要默认发送的内容  
  13. email.putExtra(android.content.Intent.EXTRA_TEXT, emailBody);  
  14. //调用系统的邮件系统  
  15. startActivity(Intent.createChooser(email, "请选择邮件发送软件"));  
原文地址:https://www.cnblogs.com/manmanlu/p/3805737.html