将 8 位 MIME 消息转换为可引用打印
将包含原始 8 位部分的 MIME 电子邮件转换为仅包含 7 位部分的 RFC822 兼容消息的最简单方法是什么?
这些部分必须自动转换为“Content-Transfer-Encoding:quoted-printable”。
我的应用程序是用 Java 开发的。但如果有一个命令行工具那就太好了。我尝试了 Reformime,但这个工具似乎有问题,并且无法正确重写消息:-(
感谢您的帮助,
奥利维尔
What is the easiest way to convert a MIME e-mail containing raw 8bit parts to a RFC822 compliant message containing only 7bit parts ?
The parts have to be automatically converted to "Content-Transfer-Encoding: quoted-printable".
My app is developed in Java. But a command-line tool would be great. I tried reformime but this tool seems buggy and doesn't rewrite message properly :-(
Thanks for any help,
Olivier
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JavaMail 似乎是一个很好的解决方案。从您的文件创建一个
MimeMessage
,找到要更改其内容传输编码的正文部分,调用MimeBodyPart.setHeader("Content-Transfer-Encoding", "quoted-printable")< /code>,并通过
MimeMessage.writeTo()
写出结果消息。大致如下:
请注意,当您对消息进行更改时,
MimeMessage
默认情况下会重置Message-ID
标头。如果您不想这样做,请将MimeMessage.updateMessageID()
重写为无操作。JavaMail seems like a good solution. Create a
MimeMessage
from your file, find the body parts whose content transfer encodings you want to change, callMimeBodyPart.setHeader("Content-Transfer-Encoding", "quoted-printable")
, and write the resulting message out viaMimeMessage.writeTo()
.Something along the lines of this:
Note that
MimeMessage
by default will reset theMessage-ID
header when you've made changes to the message. If you don't want this, overrideMimeMessage.updateMessageID()
to a no-op.