我正在使用Javamail 1.5.6实现.eml解析器,我已经开始从msghow.java复制Javamail中提供的示例。
我正在测试一个包含另一个eml作为附件的eml,这是摘录:
MIME-Version: 1.0
Date: Tue, 30 Apr 2019 16:20:45 +0200
Message-ID: <CA+fLqEW8TUfSxih9DTp2WXa63pS7wf1eZiro_9k1XS4AShN5Zg@mail.gmail.com>
Subject: Message with an eml as attachment
From: a b <ab@gmail.com>
To: cd@pec.cd.it
Content-Type: multipart/mixed; boundary="00000000000057f76c0587c01bc9"
--00000000000057f76c0587c01bc9
Content-Type: multipart/alternative; boundary="00000000000057f7670587c01bc7"
--00000000000057f7670587c01bc7
Content-Type: text/plain; charset="UTF-8"
Hello guys,
this is a simple message from a not certified account, it contains only one
attachment, an eml message
--00000000000057f7670587c01bc7
Content-Type: text/html; charset="UTF-8"
<div dir="ltr">Hello guys,<div><br></div><div>this is a simple message from a not certified account, it contains only one attachment, an eml message</div></div>
--00000000000057f76c0587c01bc9
Content-Type: message/rfc822; name="Cena zerebao.eml"
Content-Disposition: attachment; filename="Cena zerebao.eml"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_jv3vpu760
Content-ID: <f_jv3vpu760>
WC1Ob3Rlcy1JdGVtOiBGcmksIDYgSnVsIDIwMTggMTc6NDA6MDAgKzAyMDA7DQogdHlwZT00MDA7
IG5hbWU9T3JpZ2luYWxNb2RUaW1lDQpYLU5vdGVzLUl0ZW06IE1lbW87DQogbmFtZT1Gb3JtDQpY
LU5vdGVzLUl0ZW06IFN0ZE5vdGVzTHRyMjU7DQo.... and so on
Javamail可以识别该eml,但是当我获取其eject,日期,正文,附件等时,它们全为空。 msghow.java本身看不到它们。
在使用javamail之前,我使用mime4j实现了解析器,但我没有这个问题,但是现在我想尽可能仅使用javamail来解析emls
答案 0 :(得分:0)
来自描述mail.mime.allowencodedmessages
属性的javadocs:
MIME规范不允许对message / *类型的正文部分进行编码。在这种情况下,将忽略Content-Transfer-Encoding标头。某些版本的Microsoft Outlook将错误地编码邮件附件。将此系统属性设置为“ true”将使Content-Transfer-Encoding标头适合邮件附件。此属性的默认值为false。