2016-10-27 3 views
0

조직 목록에서 전자 메일 주소와 이름을 가져 오는이 코드가 있습니다.연락처 그룹 받기 전자 메일 주소

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 

연락처 그룹의 이름을 이미 가져올 수 있습니다. 하지만 이제 문제는 연락처 그룹의 이메일 주소 (예 : [email protected])를 가져올 수 없다는 것입니다. 어떤 도움이 필요합니까?

답변

0

AddressEntry.Members 컬렉션에서 반환 된 주소 항목을 반복합니다.

관련 문제