Hi all,
Is there a way to pull the members of an Outlook global distribution list via Access VBA?
Hi all,
Is there a way to pull the members of an Outlook global distribution list via Access VBA?
Moderator Bump
I expect the student to do their homework and find all the errrors I leeve in.
Please take the time to read the Forum FAQ
Yes, sure. Here is some code to retrieve the members from all distribution lists in your default contacts folder.
Public Sub PrintContactLists() Dim app As Outlook.Application Dim distListItems As Outlook.Items Dim distList As Outlook.DistListItem Dim members As String Dim i As Long Set app = New Outlook.Application Set distListItems = app.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts).Items.Restrict("[MessageClass]='IPM.DistList'") For Each distList In distListItems Debug.Print "Name: " & distList.DLName Debug.Print "Number of Members: " & distList.MemberCount For i = 1 To distList.MemberCount members = members & distList.GetMember(i).Name & ", " Next Debug.Print "Members:" & members members = "" Next distList Set distList = Nothing Set distListItems = Nothing End Sub
Learn VBA from the ground up with my VBA Online Courses.