是否可以只获取Outlook电子邮件的最顶层帖子?
说电子邮件看起来像这样......
嗨,约翰,
是的,我们可以得到!我希望...
问候,
signature_here
来自:John Doe发送时间:2015年11月4日星期三上午6:02
要: to@email.com
抄送:CC@email.com
主题:如何得到这个? 你好鲍勃,
什么东西
我只需要获得粗体文字。那可能吗?我收到电子邮件的代码:
OutLook.Application oApp;
OutLook._NameSpace oNS;
OutLook.MAPIFolder oFolder;
OutLook._Explorer oExp;
try
{
oApp = new OutLook.Application();
oNS = (OutLook._NameSpace)oApp.GetNamespace("MAPI");
oFolder = oNS.GetDefaultFolder(OutLook.OlDefaultFolders.olFolderInbox);
oExp = oFolder.GetExplorer(false);
oNS.Logon(Missing.Value, Missing.Value, false, true);
foreach (OutLook.MailItem mail in oFolder.Items.Restrict("[UnRead] = true"))
{
var subject = mail.Subject;
var body = mail.Body; //But I only need the bolded text and not the entire thread...
var x = mail.HTMLBody;
var y = mail.RTFBody;
var userName = string.Empty;
var attachment = mail.Attachments;
OutLook.ExchangeUser exUser = mail.Sender.GetExchangeUser();
if (exUser != null)
{
userName = exUser.PrimarySmtpAddress;
}
else
{
userName = mail.SenderEmailAddress;
}
mail.UnRead = false;
mail.Save();
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
oApp = null;
oNS = null;
oFolder = null;
oExp = null;
}