场景:我试图从远程Exchange服务器提取电子邮件并尝试显示详细信息,例如From,To,Body,Time等。只有在邮件未加密的情况下才能显示上述详细信息。如果它已加密,则可以访问除电子邮件正文之外的所有详细信息。电子邮件正文为null。所以请帮助我如何解密邮件并使用任何一种解密技术获取邮件正文(PKI身份验证会很好(最好))。
使用以下代码获取电子邮件项目。
ExchangeService ews = new ExchangeService(ExchangeVersion.Exchange2007_SP1)
{
Credentials = new WebCredentials("username", "password")
};
ews.AutodiscoverUrl("firstname.lastname@company.com",RedirectionUrlValidationCallback);
object o = ews.FindItems(WellKnownFolderName.Inbox, new ItemView(10));
FindItemsResults<Item> findResults = ews.FindItems(WellKnownFolderName.Inbox, new ItemView(10));
foreach (EmailMessage message in findResults.Items.Take(10))
{
//MailMessage smtpmsg = message as MailMessage;
mails.Rows.Add(message.Id.UniqueId, message.From.Name, message.Subject, message.DateTimeSent);
}
To display the body am using the following code :
PropertySet emailPropSet = new PropertySet(); emailPropSet.RequestedBodyType = BodyType.Text; emailPropSet.BasePropertySet = BasePropertySet.FirstClassProperties; EmailMessage message = EmailMessage.Bind(ews, new ItemId(uniqueId), emailPropSet);
message.Load();
lblFrom.Text = message.From.ToString();
lblSubject.Text = message.Subject;
lblBody.Text = message.Body.Text;