1
我有以下代碼從Outlook中檢索全局地址列表,然後使用名稱和部門創建一個數組。使用VBA從Outlook聯繫人獲取管理器
我想獲得用戶的經理 - 但是在屬性列表中找不到它,oUser.GetExchangeUserManager
不起作用
Dim appOL As Outlook.Application ' Object
Dim oGAL As Outlook.AddressEntries ' .NameSpace Object
Dim oContact As Outlook.AddressEntry ' Object
Dim oUser As ExchangeUser ' Object
Dim arrUsers(1 To 65000, 1 To 4) As String
Dim UserIndex As Long
Dim i As Long
Set appOL = New Outlook.Application ' CreateObject("Outlook.Application")
Set oGAL = appOL.GetNameSpace("MAPI").AddressLists("Global Address List").AddressEntries
For i = 1 To oGAL.Count
Set oContact = oGAL.Item(i)
If oContact.AddressEntryUserType = 0 Then
Set oUser = oContact.GetExchangeUser
If Len(oUser.lastname) > 0 Then
UserIndex = UserIndex + 1
arrUsers(UserIndex, 1) = oUser.Name
arrUsers(UserIndex, 2) = oUser.Department
arrUsers(UserIndex, 3) = oUser.JobTitle ' Blank
'arrUsers(UserIndex, 4) = oUser.GetExchangeUserManager ' ERROR
End If
End If
Next i
appOL.Quit
If UserIndex > 0 Then
Range("A2").Resize(UserIndex, UBound(arrUsers, 2)).Value = arrUsers
End If
Set appOL = Nothing
Set oGAL = Nothing
Set oContact = Nothing
Set oUser = Nothing
Erase arrUsers
End Sub
如何讓管理者信息的任何想法?
謝謝,但在我上面的代碼中,我在我的'oContact'對象變量中使用了'AddressEntry'。當我在oContact之後放置一個完整的停留時間段來查看成員列表時,成員列表中沒有Manager項目 –
AddressEntry.Manager早在Outlook 2000(我沒有檢查以前的版本)時就已經公開。如果該屬性被隱藏,則Intellisense不會顯示它。嘗試在代碼中輸入並使用它。 –