【问题标题】:Getting Contact Group EMail address获取联系人组电子邮件地址
【发布时间】:2016-10-27 07:22:15
【问题描述】:

我有这段代码可以获取组织列表中的电子邮件地址和姓名。

Sub Email_Extract()
Dim colAL As Outlook.AddressLists
Dim oAL As Outlook.AddressList
Dim colAE As Outlook.AddressEntries
Dim oAE As Outlook.AddressEntry
Dim oExUser As Outlook.ExchangeUser
Dim n As Long

Set colAL = Outlook.Application.Session.AddressLists

For Each oAL In colAL

If oAL.AddressListType = olExchangeGlobalAddressList Then

Set colAE = oAL.AddressEntries
    n = 2
        For Each oAE In colAE

            If oAE.AddressEntryUserType = olExchangeUserAddressEntry Then

                Set oExUser = oAE.GetExchangeUser

                ThisWorkbook.Sheets("Sheet1").Cells(n, 1).Value = oExUser.Name 'User Name
                ThisWorkbook.Sheets("Sheet1").Cells(n, 2).Value = oExUser.PrimarySmtpAddress 'SMTP address
                 n = n + 1
                   Cells(n, 1).Activate
'if a contact group
            ElseIf oAE.AddressEntryUserType = olExchangeDistributionListAddressEntry Then
                ThisWorkbook.Sheets("Sheet1").Cells(n, 1).Value = oAE.Name
                ThisWorkbook.Sheets("Sheet1").Cells(n, 2).Value = oAE.AddressEntryUserType
                ThisWorkbook.Sheets("Sheet1").Cells(n, 3).Value = oAE.Address
                ThisWorkbook.Sheets("Sheet1").Cells(n, 3).Value = oAE.Name
            n = n + 1
            Cells(n, 1).Activate
           End If
       Next
   End If
Next

我已经可以得到联系人组的名称了。但我现在的问题是我无法获取联系人组的电子邮件地址,例如 sample.sample@mail.com。有什么帮助吗?

【问题讨论】:

    标签: excel email outlook vba


    【解决方案1】:

    遍历从AddressEntry.Members 集合返回的地址条目。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多