gpt4 book ai didi

android - 电子邮件附件图片无法发送

转载 作者:行者123 更新时间:2023-11-30 04:04:50 28 4
gpt4 key购买 nike

写了一个代码来发送电子邮件附件。一旦我发送这封电子邮件,它就会在附件中添加一个垃圾值。附加部分以不同的格式编码。

Intent i = new Intent(android.content.Intent.ACTION_SEND);
i.setType("text/html");
i.putExtra(Intent.EXTRA_EMAIL, new String[] {"user_one@example.com", "user_two@example.com" });
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + sPhotoFileName));
i.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(mailBody));
startActivity(Intent.createChooser(i, "Send mail..."));

预期:它应该是编码字符串以外的附加图像文件。

任何帮助将不胜感激。提前致谢。

最佳答案

File jpegfile = new File(imageDir, "yourfilename.jpeg");

Uri jpegurl = Uri.fromFile(jpegfile);

Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("image/jpeg"); //
intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "mailid@domain.com" });
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Mail Subject");
intent.putExtra(android.content.Intent.EXTRA_CC, new String[] { "mailid@domain.com" });
intent.putExtra(Intent.EXTRA_TEXT, "Mail body text");
intent.putExtra(Intent.EXTRA_STREAM, jpegurl);

关于android - 电子邮件附件图片无法发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11881729/

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