Global Address (Distribution) Lists

  • Thread starter Thread starter Fred Block
  • Start date Start date
F

Fred Block

Hi All,

I'm using the following to get the distribution lists from the default
Contact's Folder:

Set oFolder =
oOutlookApp.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts)

This works great. However, now I'm wondering if there's a way to pull DL's
from the Global Address List (the above code pulls from the personal
contact's).

Any help is greatly appreciated! Thanks!

-- Fred
 
This code will do what you want:

Dim objAddLists As Outlook.AddressLists, objAddList As
Outlook.AddressList
Dim objAddresses As Outlook.AddressEntries, objAddress As
Outlook.AddressEntry
Dim objNS As Outlook.namespace

Set objNS = Application.GetNamespace("MAPI")
Set objAddLists = objNS.AddressLists

For Each objAddList In objAddLists
If objAddList.Name = "Global Address List" Then 'GET THE ADDRESS
LIST YOU NEED
Exit For
Else
Set objAddList = Nothing
End If
Next

If objAddList Is Nothing Then Exit Sub 'FAILED TO GET THE ADDRESS LIST
SPECIFIED

Set objAddresses = objAddList.AddressEntries

For Each objAddress In objAddresses
If objAddress.DisplayType = olDistList Then
'THIS IS A DISTRIBUTION LIST
End If
Next
 
Use Namespace.AddressLists collection instaled.
GetDefaultFolder(olFolderContacts) returns a folder with contacts, not an
address list.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Back
Top