【问题标题】:get Manager from Outlook Contacts using VBA使用 VBA 从 Outlook 联系人获取管理器
【发布时间】:2013-12-11 12:32:01
【问题描述】:

我有以下代码从 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

关于如何获取经理信息的任何想法?

【问题讨论】:

    标签: vba outlook mapi


    【解决方案1】:

    使用AddressEntry.Manager - 它将返回另一个代表经理的AddressEntry 对象。准备好处理Nulls。

    【讨论】:

    • 谢谢,但在我上面的代码中,我在oContact 对象变量中使用了AddressEntry。当我在 oContact 后添加句号或句号以查看成员列表时,成员列表中没有 Manager 项目
    • AddressEntry.Manager 早在 Outlook 2000 就已公开(我没有检查以前的版本)。如果该属性被隐藏,Intellisense 将不会显示它。尝试在您的代码中输入它并使用它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-12
    • 1970-01-01
    • 2020-09-20
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    相关资源
    最近更新 更多