如何使用 VBA 在 Outlook 的当前打开窗口中获取对邮件项目的引用? [英] How do you get a reference to the mail item in the current open window in Outlook using VBA?

查看:76
本文介绍了如何使用 VBA 在 Outlook 的当前打开窗口中获取对邮件项目的引用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以很好地放入文件夹/应用标志/设置类别的宏,但它仅适用于资源管理器中选择的当前项目.

I have a macro that works very well to place into folders / apply flags / set categories, but it only works on the current item selected in the explorer.

当我在桌面上收到电子邮件警报并单击它以打开电子邮件时,我希望能够针对该打开的项目运行相同的宏,但我找不到有关如何访问的任何文档该对象的访问方式与我访问资源管理器列表中所选项目的方式类似.

When I get an email alert on my desktop and click on it to open the email message, I would like to be able to run the same macro against that open item, but I can't find any documentation on how to access that object in a similar way to how I access the selected item in the explorer list.

我目前的选择逻辑是这样的:

My current selection logic looks like this:

Dim Item As Object
Dim SelectedItems As Selection

Set SelectedItems = Outlook.ActiveExplorer.Selection
For Each Item In SelectedItems
    With Item
        'do stuff
    End With
Next Item

推荐答案

显然这是获取当前打开项的代码:

Apparently this is the code to get the current open item:

If TypeName(Application.ActiveWindow) = "Inspector" Then
    Set Item = Application.ActiveWindow.CurrentItem

这篇关于如何使用 VBA 在 Outlook 的当前打开窗口中获取对邮件项目的引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆