vba - 从电子邮件地址获取经理
问题描述
我正在尝试获取特定人员的“经理”(并希望之后迭代目标列表)。如何为特定的电子邮件地址而不是全局地址列表执行此操作?
Dim appOL As Outlook.Application ' Object
Dim oGAL As Outlook.AddressEntries ' .NameSpace Object
Dim oContact As Outlook.AddressEntry ' Object
Dim oUser As ExchangeUser ' Object
Set appOL = New Outlook.Application ' CreateObject("Outlook.Application")
Set oGAL = appOL.GetNameSpace("MAPI").AddressLists("Global Address List").AddressEntries("first.last@email.com")
oContact = oGAL.Item(1)
MsgBox oContact.Manager
解决方案
替换行
Set oGAL = appOL.GetNameSpace("MAPI").AddressLists("Global Address List").AddressEntries("first.last@email.com")
oContact = oGAL.Item(1)
使用以下内容(假设您正在使用 Outlook 中的选定邮件):
if appOL.ActiveExplorer.Selection.Count > 0 Then
set msg = appOL.ActiveExplorer.Selection(1)
set sender = msg.Sender
if Not (sender is null) Then
set manager = sender.Manager
End If
End If
如果您使用一次性名称,请使用类似
set recip = appOL.Session.CreateRecipient("The name to resolve")
if recip.Resolve Then
set manager = recip.AddressEntry.Manager
End If
推荐阅读
- automator - 如何更改自动化应用程序的图标?
- python - 如何从 Twilio IVR 系统获取当前来电号码?
- c# - .net 核心项目的 Visual Studio 2017 问题
- javascript - 如何创建视频和画布然后将其绘制到画布上?
- c++ - 编写一个函数接受 2 个参数——指针头或尾加上链表的遍历方向
- ruby-on-rails - Active Admin - 自定义顺序/排序,在 has_many 到 has_many 多态中的位置
- python - 如何将浮动散景标签显示到小数点后 2 位
- php - mod_rewrite 多域名
- visualization - Vega-Lite:是否可以根据日期/时间范围定义选择?
- ios - Swift:无法在初始化时将类型“()”的值转换为指定类型