我有一个名为 email_archive 的电子邮件数据库表。该表包括一个名为 body 的字段和另一个名为 raw_headers 的字段。我想使用 C#(在 SharePoint webpart 中)在屏幕上显示此表的内容。我一直在尝试找到一个可以解析正文的库,以便我可以将消息的部分返回到窗口。我尝试了 Limilabs 的一个库,并下载了其他几个库。但是,所有这些似乎都至少需要 EML 格式的电子邮件。
最近的尝试是尝试使用MailUtilies。
MimeMessage mm = new MimeMessage(header + message);
但这失败了,因为格式似乎没有通过 MimeMessage 完整性检查。
有谁知道使用原始标题和正文内容将电子邮件解析为其组成部分的方法。
标题看起来像这样
MIME-Version: 1.0
Received: from server.domain.com (10.20.205.104) by
mail.domain.com (xx.xx.xx.xx) with Microsoft SMTP Server id
8.1.436.0; Mon, 16 Sep 2013 14:33:54 -0700
Received: from server (localhost.localdomain [127.0.0.1]) by
server.domain.com (8.13.8/8.13.8) with ESMTP id r8GLX4vm007046 for
<myaddress@domain.com>; Mon, 16 Sep 2013 14:33:04 -0700
From: "service@domain.com" <service@domain.com>
To: My Name <myaddress@domain.com>
Date: Mon, 16 Sep 2013 14:33:04 -0700
Subject: Some Topic
Thread-Topic: Some Topic
Thread-Index: Ac6zJHFgOvb7ZAdeTJC8DzqnAvdnOw==
Message-ID: <153372.442207427-sendEmail@gserver>
Reply-To: "service@domain.com" <service@domain.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 10
X-MS-Exchange-Organization-AuthSource: mail.domain.com
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
Content-Type: multipart/alternative;
boundary="_000_153372442207427sendEmailgroundwork_"
消息看起来像这样
--_000_153372442207427sendEmailgroundwork_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Some message to dispaly
--_000_153372442207427sendEmailgroundwork_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<html><head><style type=3D'text/css'> p,h1 { font-family: arial; }
</style></head><body>
<p>Some message to display</p>
</body></html>
--_000_153372442207427sendEmailgroundwork_--