GetMember 方法

       

返回代表通讯组列表中成员的 Recipient 对象。

expression.GetMember(Index)

expression  必选。该表达式返回 DistListItem 对象。

Index  必选,Long 类型。要检索的成员的索引号。

示例

本 Microsoft Visual Basic/Visual Basic for Applications 示例在默认的“联系人”文件夹中查找每个通讯组列表,并确定该列表是否包含当前用户。

Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myDistList As Outlook.DistListItem
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderContacts)
For x = 1 To myFolder.Items.Count
    If TypeName(myFolder.Items.Item(x)) = "DistListItem" Then
        Set myDistList = myFolder.Items.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

如果使用 VBScript,则不创建 Application 对象,而且也不能使用命名常量。本示例说明如何使用 VBScript 执行相同任务。

Set myNameSpace = Application.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(10)
For x = 1 To myFolder.Items.Count
    If TypeName(myFolder.Items.Item(x)) = "DistListItem" Then
        Set myDistList = myFolder.Items.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