|
需要引用Microsoft Office Outlook Object x.x library
把GAL里面的所有人员信息导入excel- Sub GetGALUserList()
- Dim oGAL As AddressList
- Set oGAL = GetObject("", "Outlook.application").GetNamespace("MAPI").AddressLists.Item("Global Address List")
- Dim oEntry As AddressEntry, oEachUser As ExchangeUser
- i = 2
- On Error Resume Next
- For Each oEntry In oGAL.AddressEntries
- If oEntry.AddressEntryUserType = olExchangeUserAddressEntry Then
- Set oEachUser = oEntry.GetExchangeUser()
- Cells(i, 1).Select
- Cells(i, 1) = oEachUser.Alias
- Cells(i, 2) = oEachUser.PrimarySmtpAddress
- Cells(i, 3) = oEachUser.City
- Cells(i, 4) = oEachUser.BusinessTelephoneNumber
- i = i + 1
- End If
- Next
- End Sub
复制代码 |
|