DistListItem.GetMember Method (Outlook)

Published: July 16, 2012

Returns a Recipient object representing a member in a distribution list.

expression .GetMember(Index)

expression A variable that represents a DistListItem object.

Parameters

Name

Required/Optional

Data Type

Description

Index

Required

Long

The index number of the member to be retrieved.

Return Value

A Recipient object representing the specified member.

This Microsoft Visual Basic for Applications (VBA) example locates every distribution list in the default Contacts folder and determines whether the list contains the current user.

Sub DisplayYourDLNames() 
 
 Dim myNameSpace As Outlook.NameSpace 
 
 Dim myFolder As Outlook.Folder 
 
 Dim myDistList As Outlook.DistListItem 
 
 Dim myFolderItems As Outlook.Items 
 
 Dim x As Integer 
 
 Dim y As Integer 
 
 Dim iCount As Integer 
 
 
 
 Set myNameSpace = Application.GetNamespace("MAPI") 
 
 Set myFolder = myNameSpace.GetDefaultFolder(olFolderContacts) 
 
 Set myFolderItems = myFolder.Items 
 
 iCount = myFolderItems.Count 
 
 For x = 1 To iCount 
 
 If TypeName(myFolderItems.Item(x)) = "DistListItem" Then 
 
 Set myDistList = myFolderItems.Item(x) 
 
 For y = 1 To myDistList.MemberCount 
 
 If myDistList.GetMember(y).Name = myNameSpace.CurrentUser.Name Then 
 
 MsgBox "Your are a member of " & myDistList.DLName 
 
 End If 
 
 Next y 
 
 End If 
 
 Next x 
 
End Sub

Community Additions

ADD
Show:
© 2014 Microsoft