以编程方式获取从显示名称开始的所有可能电子邮件地址的列表

Get programmatically the list of all possible email addresses starting from Display Name

如何以编程方式(使用 VBA Excel 宏)访问我拥有其用户主体名称的单个联系人的 Outlook 属性?

我对标有“电子邮件地址”的选项卡特别感兴趣。

我设法获得了 PrimarySMTP 属性,但我想获得那里列出的所有地址的列表。 'alias' 属性 只给了我一个条目,而还有其他几个条目。

这就是我为获得通讯组列表成员所做的工作:

Dim objExchUsr As ExchangeUser 
Dim myolApp As Outlook.Application 
Dim myNameSpace As Namespace 
Dim MyAddrList As AddressList 
Dim myRecipient As Outlook.Recipient 
Dim oDistListEntries As Outlook.AddressEntries
Dim oAE As Outlook.AddressEntry

Set myolApp = CreateObject("Outlook.Application")
Set myNameSpace = myolApp.GetNamespace("MAPI")
Set MyAddrList = myNameSpace.addressLists("Global Address List")
Set myRecipient = myNameSpace.CreateRecipient(strDisplayname)
myRecipient.Resolve
If myRecipient.Resolved Then
    Set objExchUsr = myRecipient.AddressEntry.GetExchangeUser
    Set oDistListEntries = objExchUsr.GetMemberOfList
    For Each oAE In oDistListEntries
         If oAE.AddressEntryUserType = olExchangeDistributionListAddressEntry Then
           <Do something with the distribution lists: not relevant  to this problem>
         End If
    Next
End If

虽然使用此代码我获得了 Outlook 属性 'Member Of' 选项卡中显示的信息,但我的问题是如何获取选项卡 'E-mail Addresses'[=11= 中显示的信息]

提前致谢

您需要使用 AddressEntry.PropertyAccessor.GetProperty 阅读 PR_EMS_AB_PROXY_ADDRESSES MAPI 属性(DASL 名称 "http://schemas.microsoft.com/mapi/proptag/0x800F101F")。您将得到一组以地址类型为前缀的代理地址(例如“EX:”或“SMTP:”)

这是您可以使用的代码:

Const PR_EMS_AB_PROXY_ADDRESSES  As String = _
"http://schemas.microsoft.com/mapi/proptag/0x800F101F"

Dim NS As Outlook.NameSpace
Set NS = Application.GetNamespace("MAPI")

addresses = _
NS.CurrentUser.AddressEntry.PropertyAccessor.GetProperty(PR_EMS_AB_PROXY_ADDRESSES)