Global Address (Distribution) Lists

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
 
E

Eric Legault [MVP - Outlook]

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
 
D

Dmitry Streblechenko \(MVP\)

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
 

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