GetMember Method

Microsoft Outlook Visual Basic

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

expression.GetMember(Index)

expression    Required. An expression that returns a DistListItem object.

Index    Required Long. The index number of the member to be retrieved.

Remarks

If a program tries to reference any type of recipient information by using the Microsoft Outlook object model, a dialog box is displayed that asks you to confirm access to this information. You can allow access to the Address Book or recipient information for up to ten minutes after you receive the dialog box. This allows features, such as mobile device synchronization, to be completed.

You receive the confirmation dialog box when a solution tries to programmatically access the GetMember method.

Example

This Microsoft Visual Basic/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 myOlApp As New Outlook.Application
	Dim myNameSpace As Outlook.NameSpace
	Dim myFolder As Outlook.MAPIFolder
	Dim myDistList As Outlook.DistListItem
	Dim myFolderItems As Outlook.Items
	Dim x As Integer
	Dim y As Integer
	Dim iCount As Integer
	Set myNameSpace = myOlApp.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
		

If you use Microsoft Visual Basic Scripting Edition (VBScript) in an Outlook form, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript code.

Set myNameSpace = Application.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(10)
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 
    End If
Next