美文网首页
Android发送邮件(Send Email)

Android发送邮件(Send Email)

作者: zhujunhua | 来源:发表于2020-09-14 13:46 被阅读0次

Andorid 调用其他app发送Email。

  1. Intent.ACTION_SENDTO
            // 1. 注意使用 Uri.encode()
            Uri uri = Uri.parse("mailto:" + email
                    + "?subject=" + Uri.encode(subject)
                    + "&body=" + Uri.encode(content));
            Intent emailIntent = new Intent(Intent.ACTION_SENDTO, uri);
  1. Intent.ACTION_SEND, 有一些其他非email类的app也会弹出来
            Intent emailIntent = new Intent(Intent.ACTION_SEND);
            emailIntent.setType("text/html");
            emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{email});
            emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
            emailIntent.putExtra(Intent.EXTRA_TEXT, content);

参考:
stackoverflow

相关文章

网友评论

      本文标题:Android发送邮件(Send Email)

      本文链接:https://www.haomeiwen.com/subject/dnmbektx.html