使用android-Intent发送邮件失败

时间:2014-10-15 12:00:27

标签: android android-intent

我正在尝试使用intent创建电子邮件。我有以下代码:

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setData(Uri.parse("mailto:"));
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_EMAIL,
        "bla@test.com");
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT, "I'm email body.");

startActivity(intent);

此后邮件客户端打开,主题和文本被填充,但电子邮件地址仍为空。有谁知道它失败的原因?

1 个答案:

答案 0 :(得分:1)

Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{"youremail@yahoo.com"});          
email.putExtra(Intent.EXTRA_SUBJECT, "subject");
email.putExtra(Intent.EXTRA_TEXT, "message");
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose an Email client :"));

Look This