You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用VBA从GAL的ExchangeUser.Department字段获取指定部门所有成员

问题说明
  • 核心需求:借助VBA实现Outlook通讯簿的高级搜索功能,支持查询指定部门的所有成员。
  • 现有参考实现:仅支持输入用户ID/别名来查询该用户的其他相关信息,代码如下:
Public Function GetDepartment(var1)

    Dim outApp As Object 'Application
    Dim outTI As Object 'TaskItem
    Dim outRec As Object 'Recipient
    Dim outAL As Object 'AddressList

    Set outApp = GetObject(, "Outlook.Application")
    Set outAL = outApp.Session.addressLists.Item("Global Address List")
    Set outTI = outApp.CreateItem(3)
    
    outTI.Assign
    
    Set outRec = outTI.Recipients.Add(var1)
    outRec.Resolve
    If outRec.Resolved Then
        'MsgBox outRec.addressEntry.Name
        Department = outRec.addressEntry.GetExchangeUser.Department
        'MsgBox outRec.addressEntry.GetExchangeUser.JobTitle
        'MsgBox outRec.addressEntry.GetExchangeUser.
        'MsgBox outAL.addressEntries(outRec.addressEntry.manager.Name).GetExchangeUser.Alias
    Else
        Department = "Couldn't find Employee Department"
    End If
  
    GetDepartment = Department  
    
End Function
  • 疑问:由于GAL内条目数量庞大,遍历查询方法可行性极低,请问是否可以修改对应List members功能实现上述需求?

内容的提问来源于stack exchange,提问作者Jesper

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.03 10:54:04