gpt4 book ai didi

java - Apache Commons Email,如何使用 Content-Transfer-Type 作为 quoted-printable 发送电子邮件附件?

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:31:41 24 4
gpt4 key购买 nike

我有一个应用程序可以通过发送带附件的电子邮件与其他人的服务器通信。

我使用 Apache Commons Email 发送带有附件的电子邮件,如下所示:

MultiPartEmail email = new MultiPartEmail();
email.setHostName(sHostName);
email.addTo("bob@bob.com");
email.addFrom("andy@andy.com");
email.setSubject("the subject");
email.setMsg("the message");

byte[] documentFile = /* ... */;
String filename = "my file.pdf";
String description = "this is my file";

email.attach(new ByteArrayDataSource(myPDF, "application/pdf"), filename, description, EmailAttachment.ATTACHMENT);

email.send();

问题是,另一端的人说“ header 信息的 Content-Transfer-Encoding 值为“7bit”,需要“quoted-printable”。

我的问题是,如何进行此更改以便以适当的方式附加文件?

罗布

最佳答案

Commons 电子邮件根据附件的内容决定使用哪种编码,参见 http://thecarlhall.wordpress.com/2010/09/01/setting-quoted-printable-in-a-commons-email-body-part/进行一些相关的讨论。此外,底层的 java-mail 似乎会根据 javadoc 自动执行此操作。 .

博文说你可以尝试使用

email.addHeader("Content-transfer-encoding", "quoted-printable");

但它可能会因此损坏邮件的其他部分。

关于java - Apache Commons Email,如何使用 Content-Transfer-Type 作为 quoted-printable 发送电子邮件附件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13144171/

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