【发布时间】:2014-11-14 23:37:15
【问题描述】:
我正在尝试在 Outlook 中提取多部分邮件的正文部分的标题。原始消息(我无法从我的代码中获得)看起来像这样:
Return-Path: ...
Received: ...
From: ...
Content-Type: multipart/signed; boundary="Apple-Mail=_06FDFEBB-366E-4B1E-AA7F-F5DDEC13FD03"; protocol="application/pgp-signature"; micalg=pgp-sha512
Subject: ...
Message-Id: ...
Date: ...
To: ...
Mime-Version: ...
X-Mailer: ...
--Apple-Mail=_06FDFEBB-366E-4B1E-AA7F-F5DDEC13FD03
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=us-ascii
...
--Apple-Mail=_06FDFEBB-366E-4B1E-AA7F-F5DDEC13FD03
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename=signature.asc
Content-Type: application/pgp-signature;
name=signature.asc
Content-Description: Message signed with OpenPGP using GPGMail
...
--Apple-Mail=_06FDFEBB-366E-4B1E-AA7F-F5DDEC13FD03--
我用点替换了一些不相关的部分。我试图获得的标题是第一个边界下的标题。所以这是我正在寻找的部分:
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=us-ascii
但是,如果我可以得到边界之间的整个部分,那也很好,因为我可以自己解析它。
到目前为止,我只能获取邮件顶部的标题(所以从Return-Path 到X-Mailer)。
我可以通过以下方式使用 `PropertyAccessor 来做到这一点:
mailItem.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x007D001E")
在这种情况下,mailItem 是我的 Microsoft.Office.Interop.Outlook.MailItem 实例。
那么,我的问题归结为:我怎样才能得到第一个边界下的标题,或者包含它们的消息的任何更大部分?
【问题讨论】:
标签: c# email outlook multipart