Consulting

Results 1 to 3 of 3

Thread: Outlook Distribution

  1. #1
    VBAX Newbie
    Joined
    Jul 2016
    Posts
    3
    Location

    Outlook Distribution

    Hi all,

    Is there a way to pull the members of an Outlook global distribution list via Access VBA?

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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

  3. #3

    Post

    Quote Originally Posted by ry94080 View Post
    Is there a way to pull the members of an Outlook global distribution list via Access VBA?
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •