2016-10-27 38 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コレクションから返されたアドレスエントリをループします。

関連する問題