在我的 VSTO Outlook 2007 插件中,我能够获取作为交换用户的收件人的电子邮件地址。但是当我遇到以下情况时,它不会返回 smtp 电子邮件:
下面是我的代码:
Recipient r = mailItem.Recipients[i];
r.Resolve();
//Note, i have different conditions that check the AddressEntryUserType of recipient's
//address entry object. All other cases work fine. In this case this is
//olOutlookContactAddressEntry.
//I have tried the following:
ContactItem cont = r.AddressEntry.GetContact();
string email = cont.Email1Address;
string emailtmp = r.AddressEntry.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x800F101E") as string;
任何人都可以帮助我了解在这种情况下我应该使用什么属性来获取 smtp 电子邮件?
最佳答案
我找到了一种使用 ExchangeUser 项目并通过该对象解析 smtp 地址的方法。这篇文章有帮助 - Get Smtp email from ContactInfo stored in Exchange
foreach (Outlook.Recipient recipient in currentAppointment.Recipients)
{
Outlook.ExchangeUser exchangeUser = recipient.AddressEntry.GetExchangeUser();
string smtpAddress;
if (exchangeUser != null)
{
smtpAddress = exchangeUser.PrimarySmtpAddress;
}
else
{
smtpAddress = recipient.Address;
}
}
关于ms-office - 获取作为交换用户的收件人的电子邮件地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6219665/