gpt4 book ai didi

android - 使用 Intent 时不显示电子邮件正文

转载 作者:太空宇宙 更新时间:2023-11-03 12:20:50 25 4
gpt4 key购买 nike

当我尝试发送电子邮件 Intent 时,无论我是使用 INTENT.ACTION_SEND 还是 ACTION.SENDTO 并使用库存的 Sony Xperia Active 电子邮件客户端,主题和收件人都显示正常,但正文是空的,除了标准客户粘贴的评论。在我的 Samsung Galaxy Note 2 上,相同的代码非常有效。

    if(mPrefs.getBoolean("alternative_email_client", false)){
Intent send = new Intent(Intent.ACTION_SENDTO);
String uriText = "mailto:" + Uri.encode(emailStrings[6]) +
"?subject=" + Uri.encode("The subject") +
"&body=" + Uri.encode(emailBody);
Uri uri = Uri.parse(uriText);
send.setData(uri);
startActivity(Intent.createChooser(send, "Email verschicken"));
} else {
Intent send = new Intent(Intent.ACTION_SEND);
send.putExtra(Intent.EXTRA_EMAIL, emailStrings[6]);
send.putExtra(Intent.EXTRA_SUBJECT, "The Subject");
send.putExtra(Intent.EXTRA_TEXT, emailBody);
startActivity(Intent.createChooser(send, "Email verschicken"));
}

最佳答案

要发送带有正文的电子邮件,请使用 message/rfc822。

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("message/rfc822");
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "to1@example.com", "to2@example.com" });
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject of the email");
sendIntent.putExtra(Intent.EXTRA_TEXT, "Content of the email");
startActivity(sendIntent);

希望这对您有所帮助。

关于android - 使用 Intent 时不显示电子邮件正文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16500545/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com