如何使用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
相关产品推荐
相关产品推荐

