zoukankan      html  css  js  c++  java
  • 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, "请选择邮件发送软件"));  
  • 相关阅读:
    密码学
    MD5
    计算机基础之操作系统
    python中列表之间求差集、交集、并集
    Python语言中各种进制相互转换
    计算机基础
    bzoj2705 [SDOI2012]Longge的问题
    bzoj3160 万径人踪灭
    codeforces 528D Fuzzy Search
    杜教筛 && bzoj3944 Sum
  • 原文地址:https://www.cnblogs.com/manmanlu/p/3805737.html
Copyright © 2011-2022 走看看