Android发送邮件,并弹出邮箱类应用供选择

来源:互联网 发布:阿里云服务器esc 编辑:程序博客网 时间:2024/05/30 02:26
转自:http://www.apkbus.com/home.php?mod=space&uid=57740&do=blog&id=56920

public class MailClientChoose {
    public static void mailContact(Context c, String mailAdress) {

        Uri uri = Uri.parse("mailto:"+mailAdress); 
        Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
        //intent.putExtra(Intent.EXTRA_CC, email); // 抄送人
       // intent.putExtra(Intent.EXTRA_SUBJECT, "这是邮件的主题部分"); // 主题
       // intent.putExtra(Intent.EXTRA_TEXT, "这是邮件的正文部分"); // 正文
        c.startActivity(Intent.createChooser(intent, "请选择邮件类应用"));
    }
}


有两点需要注意:

(1):必须使用Intent.ACTION_SENDTO,而不是Intent.ACTION_SEND。否则就会出现很多非邮箱类应用

(2):必须用  : Uri uri = Uri.parse("mailto:"+mailAdress); 
                           Intent intent = new Intent(Intent.ACTION_SENDTO, uri);

而不是 :Intent intent = new Intent(Intent.ACTION_SENDTO);
          intent.putExtra(Intent.EXTRA_EMAIL, mailAdress);

否则找不到邮箱类应用


0 0
原创粉丝点击