从存储在 Exchange 中的 ContactInfo 获取 Smtp 电子邮件 [英] Get Smtp email from ContactInfo stored in Exchange

查看:63
本文介绍了从存储在 Exchange 中的 ContactInfo 获取 Smtp 电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 VSTO 用于 Outlook 加载项.目前我正在处理所有 Outlook 联系人的电子邮件地址.如果 EmailAddress1Type 为SMTP",则 ContactInfo 实例没有问题.

I am using VSTO for my Outlook add-in. Currently I am processing email addresses from all Outlook contacts. There is no problem for instances of ContactInfo if EmailAddress1Type is "SMTP".

但是如何获取 Exchange 联系人的电子邮件地址 (Email1AddressType = "EX")?

But how to get email address for Exchange contact (Email1AddressType = "EX")?

赎回库对我来说不是解决方案,因为仅仅解决这个问题就很昂贵.

Redemption library is not solution for me as it is expensive just to solve this one problem.

先谢谢你,

杜尚

推荐答案

这里是 MSDN 参考链接 和对应的示例代码:

Here is the MSDN reference link and corresponding sample code:

private const string Email1EntryIdPropertyAccessor = "http://schemas.microsoft.com/mapi/id/{00062004-0000-0000-C000-000000000046}/80850102";

PropertyAccessor propertyAccessor = contactItem.PropertyAccessor;
object rawPropertyValue = propertyAccessor.GetProperty(Email1EntryIdPropertyAccessor);
string recipientEntryID = propertyAccessor.BinaryToString(rawPropertyValue);
Recipient recipient = contactItem.Application.Session.GetRecipientFromID(recipientEntryID);
if (null == recipient)
    throw new InvalidOperationException();

bool wasResolved = recipient.Resolve();
if (!wasResolved)
    throw new InvalidOperationException();
ExchangeUser exchangeUser = recipient.AddressEntry.GetExchangeUser();
string smtpAddress = exchangeUser.PrimarySmtpAddress;

这篇关于从存储在 Exchange 中的 ContactInfo 获取 Smtp 电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆