Java 电子邮件消息解析器?
有人熟悉可以帮助解析下面电子邮件的字段(日期、主题、发件人、收件人)的 Java 库吗?
Message-ID: <19815303.1075861029555.JavaMail.ss@kk>
Date: Wed, 6 Mar 2010 12:32:20 -0800 (PST)
From: [email protected]
To: [email protected]
Subject: some subject
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-From: one, some <[email protected]>
X-To: one
X-cc:
X-bcc:
X-Folder: Bob\Inbox
X-Origin: Bob-R
X-FileName: rbob (Non-Privileged).pst
some message
Is anyone familiar with a Java library that helps with parsing the fields (date, subject, from, to) of the email below?
Message-ID: <19815303.1075861029555.JavaMail.ss@kk>
Date: Wed, 6 Mar 2010 12:32:20 -0800 (PST)
From: [email protected]
To: [email protected]
Subject: some subject
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-From: one, some <[email protected]>
X-To: one
X-cc:
X-bcc:
X-Folder: Bob\Inbox
X-Origin: Bob-R
X-FileName: rbob (Non-Privileged).pst
some message
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
JavaMail 是一个 oracle 库,提供邮件服务和邮件相关服务(例如解析 javax.mail 包中的常规和 MIME 消息。此外,Apache 还有一个用于邮件处理的 Commons Email 库。
在 JavaMail api 中,解析包含电子邮件消息(可能是也可能不是显式 MIME)的字符串的简单方法如下,
并且可以像这样解析标头
JavaMail is an oracle library that provides mail services and mail related services (like parsing conventional & MIME messages) in the javax.mail package. Additionally Apache has a Commons Email library for mail handling.
In the JavaMail api, a simple way to parse a string containing an email message (which may or may not be explicitly MIME) would be as follows
and parsing the headers could be done like this
我在使用 JavaMail 时遇到了问题(它无法解析一些它应该解析的电子邮件消息)。
我使用 Mime4J 获得了更好的结果。
I have had problems with JavaMail (it fails to parse some email messages that it should).
I have had much better results with Mime4J.
我建议您使用 email-mime-parser,
以下示例代码给出您需要的所有相关信息:
I would suggest you use email-mime-parser,
Following sample code gives you all the relevant info you need: