如何从MS outlook 2010获取电子邮件地址
本文关键字:2010 获取 电子邮件地址 outlook MS | 更新日期: 2023-09-27 18:28:13
这是我用来检索MS outlook邮件-的代码
NameSpace _nameSpace;
ApplicationClass _app;
_app = new ApplicationClass();
_nameSpace = _app.GetNamespace("MAPI");
object o = _nameSpace.GetItemFromID(EntryIDCollection);
MailItem Item = (MailItem)o;
string HTMLbpdyTest = Item.HTMLBody;
CreationTime = Convert.ToString(Item.CreationTime);
Outlook.Recipients olRecipients = default(Outlook.Recipients);
olRecipients = Item.Recipients;
string strCcEmails = string.Empty;
foreach (Outlook.Recipient olRecipient in Item.Recipients)
{
if (olRecipient.Type == Outlook.OlMailRecipientType.olCC)
{
strCcEmails = olRecipient.Address;
}
}
当使用MAPI从MS outlook 2010检索CC电子邮件地址时,它给出了这种格式的输出-
strCcEmails = /O=EXG5/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=Test88067
如何获取确切的电子邮件地址?
使用Recipient.AddressEntry.GetExchangeUser.PrimarySmtpAddress
(省略错误/null检查)。
尝试http://msdn.microsoft.com/en-us/library/office/ff868695.aspx
具体而言:
Outlook.PropertyAccessor pa = olRecipient.PropertyAccessor;
string smtpAddress = pa.GetProperty(PR_SMTP_ADDRESS).ToString();
Debug.WriteLine(olRecipient.Name + " SMTP=" + smtpAddress);