【问题标题】:Retrieve members of nested Outlook distribution list with VBA使用 VBA 检索嵌套 Outlook 通讯组列表的成员
【发布时间】:2020-06-26 06:54:23
【问题描述】:

我想检索 Outlook 通讯组列表的成员。他们中的大多数只包含联系人。然而,奇怪的是,我发现其中一些可以控制自己。在 Outlook 中双击它们时,我可以看到它们的成员,但我想不出在 VBA 中访问它们的可能性。

以下代码打印本地联系人列表中所有通讯组列表中的所有成员,但是,正如我所提到的,对于某些通讯组列表,它只会打印自己。

示例结果如下所示: PDL - 样本列表 PDL - sampleList -- sampleList@company.com

Sub test()

Dim objDistList As DistListItem

Const olFolderContacts = 10

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")

Set colContacts = objNamespace.GetDefaultFolder(olFolderContacts).Items
intCount = colContacts.Count

For i = 1 To intCount
    If TypeName(colContacts.Item(i)) = "DistListItem" Then
        Set objDistList = colContacts.Item(i)
        Debug.Print objDistList.DLName
        For j = 1 To objDistList.MemberCount
    Debug.Print objDistList.GetMember(j).Name & " -- " & objDistList.GetMember(j).Address
        Next
    End If
Next

End Sub

【问题讨论】:

    标签: vba outlook


    【解决方案1】:

    如何检查从 GetMember 返回的 Recipient.DisplayType 是否属于 OlDisplayType.olPrivateDistList 类型?然后你就会知道将其解析为 DL 中的嵌入式 DL。

    【讨论】:

      猜你喜欢
      • 2017-03-24
      • 1970-01-01
      • 1970-01-01
      • 2014-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-11
      • 1970-01-01
      相关资源
      最近更新 更多