Accessing Global Address List details with VBA

D

Dugutigi

I have code that reads names from a local Distribution List and looks up the
name in the Global Address List. The purpose is to retrieve a few of the
details about the user that appear in the properties dialog box ... such as
Street Address, City and State.

My problem is that I only have Outlook 2003 which apparently does not have
the GetExchangeUser object. How can I retrieve these pieces of information
without the GetExchangeUser object?

Here is my code so far ... which works as long as I have manually selected
my local Distribution List. Thanks in advance for any help.

Dim olkDL As Outlook.DistListItem
Dim olkEntry As Outlook.Recipient
Dim olkContact As Outlook.ContactItem
Dim intCount As Integer
Dim strAddress As String
Dim strName As String

Dim oApp As Outlook.Application
Dim oNS As Outlook.NameSpace
Dim oALs As Outlook.AddressLists
Dim oGal As Outlook.AddressList
Dim oEntries As Outlook.AddressEntries
Dim oEntry As Outlook.AddressEntry

Dim x As Long

Set oApp = Outlook.Application
' Get the MAPI namespace.
Set oNS = oApp.Session
' Get the Global Address List.
Set oALs = oNS.AddressLists
Set oGal = oALs.Item("Global Address List")
' Get all the entries.
Set oEntries = oGal.AddressEntries

' Get the first user.
Set oEntry = oEntries.GetFirst()

'Get the currently selected distribution list'
Set olkDL = Application.ActiveExplorer.Selection(1)
For intCount = 1 To olkDL.MemberCount
Set olkEntry = olkDL.GetMember(intCount)
For x = 1 To oEntries.Count
strName = olkEntry.AddressEntry.Name
If oEntry.Name = strName Then
Debug.Print oEntry.Name & ";" & oEntry.Address
GoTo NextIntCount
End If
Set oEntry = oEntries.GetNext
Next x

NextIntCount:
Next intCount


Set olkEntry = Nothing
Set olkDL = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top