在我的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电子邮件?
答案 0 :(得分:4)
我找到了一种方法来使用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;
}
}
答案 1 :(得分:0)
如果我没记错的话,有几个情况下电子邮件地址无法解决,除非您首先保存了要发送的项目。你可以尝试一下。此外,您是否收到任何“安全违规”消息,要求获得访问用户地址簿的权限,或者您是否已禁用/解决所有这些问题?我有很多问题,最终需要使用Redemption for outlook。