C# outlook联系人可以';无法获取SMTP地址,在“上没有MAPI属性”;交换;联系人名单

C# outlook联系人可以';无法获取SMTP地址,在“上没有MAPI属性”;交换;联系人名单,c#,outlook,exchange-server,mapi,exchange-server-2010,C#,Outlook,Exchange Server,Mapi,Exchange Server 2010,它是outlook中的一个bug吗 我创建了一张本地联系人列表卡,并在地址字段中为他提供了一个交换用户的地址。(双击该地址,查看其交换) 当我尝试使用MAPI获取地址时-我无法,问题是,当我检查AddressEntry对象时,我得到以下结果: Type=“EX” Address=“/o=…/ou=Exchange…”/cn=Recipients/cn=Name Class=olAddressEntry AddressEntryUserType=olOutlookContactAddressEn

它是outlook中的一个bug吗

我创建了一张本地联系人列表卡,并在地址字段中为他提供了一个交换用户的地址。(双击该地址,查看其交换)

当我尝试使用MAPI获取地址时-我无法,问题是,当我检查AddressEntry对象时,我得到以下结果:

  • Type=“EX”
  • Address=“/o=…/ou=Exchange…”/cn=Recipients/cn=Name
  • Class=olAddressEntry
  • AddressEntryUserType=olOutlookContactAddressEntry
当我签入OutlookSpy时-没有MAPI属性,因此我无法获取PR_SMTP_地址或PR_EMS_AB_代理_地址,而且,这不是SMTP,因此我没有有效地址


我检查了其他用户,这些是属性(它可以工作):

真正的exchange用户收件人,与exchange用户的电子邮件地址相同,但创建时没有自动更正到exchange用户,因此它保持smtp:

  • Type=“SMTP”
  • 地址=”Email@email.com"
  • Class=olAddressEntry
  • AddressEntryUserType=olExchangeUserAddressEntry
常规地址条目

  • Type=“EX”
  • Address=“/o=…/ou=Exchange…”/cn=Recipients/cn=Name
  • Class=olAddressEntry
  • AddressEntryUserType=olOutlookContactAddressEntry
如果双击“exchange”本地联系人,它将打开其属性的exchange窗口,如果我打开“我手动创建的常规联系人”,则会打开“SMTP”地址窗口

我能做些什么


谢谢。

如果您有EX-type联系人,请使用ContactItem.Email1EntryId属性的值调用
命名空间GetAddressEntryFromId
,然后读取
AddressEntry.GetExchangeUser.PrimarySmtpAddress
属性。

由于某些原因,它没有按照“Dmitry Streblechenko”建议的方式工作 ContactItem.Email1EntryId、ContactItem.Email2EntryId和ContactItem.Email3EntryId不包含id,但包含一些错误的随机数据(甚至一些html标记)-office 2016

但它最终使用了以下代码

 using (var pa = new InteropWrapper<Outlook.PropertyAccessor>(contact.innerObject.PropertyAccessor))
            {
                String EMAIL1_ENTRYID = "http://schemas.microsoft.com/mapi/id/{00062004-0000-0000-C000-000000000046}/80850102";
                string emailEntryID = pa.innerObject.BinaryToString(pa.innerObject.GetProperty(EMAIL1_ENTRYID));

                using (var rs = new InteropWrapper<Outlook.NameSpace>(Globals.ThisAddIn.Application.Session))
                {
                    rs.innerObject.Logon();
                    using (var addressEntry = new InteropWrapper<Outlook.AddressEntry>(rs.innerObject.GetAddressEntryFromID(emailEntryID)))
                    using (var exchangeUser = new InteropWrapper<Outlook.ExchangeUser>(addressEntry.innerObject.GetExchangeUser()))
                    {
                        return exchangeUser.innerObject.PrimarySmtpAddress;
                    }
                }
            }
希望它能节省一些人的时间!我花了差不多一天的时间

String EMAIL2_ENTRYID = "http://schemas.microsoft.com/mapi/id/{00062004-0000-0000-C000-000000000046}/80950102";
String EMAIL3_ENTRYID = "http://schemas.microsoft.com/mapi/id/{00062004-0000-0000-C000-000000000046}/80A50102";