VBA: Get programmatically the list of all possible email addresses starting from Display Name or UPN

Massimo Sartoris 1 Reputation point
2022-03-25T12:48:54.927+00:00

Hello everybody

How could I get programmatically (with a VBA Excel macro) access to the Outlook properties of a single contact for whom I have the User Principal Name or the Display Name

I am interested in particular to the tab labelled "E-mail Addresses" of the Outlook Properties

I managed to get the PrimarySMTP property, but I would like to get the list of all addresses that are listed there. The 'alias' property only gives me one entry, while there are several others.

I managed to write some code to get the information concerning the distribution list membership information, this is what I did:

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

While with this code I get the information shown in the tab 'Member Of' of the Outlook Properties, my problem is how to get the information that is shown in the tab 'E-mail Addresses'

Thank you in advance

Outlook Management
Outlook Management
Outlook: A family of Microsoft email and calendar products.Management: The act or process of organizing, handling, directing or controlling something.
4,885 questions
Exchange Server Development
Exchange Server Development
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Development: The process of researching, productizing, and refining new or existing technologies.
508 questions
0 comments No comments
{count} votes