如何使用 VBA 获取对 Outlook 当前打开窗口中的邮件项的引用?
我有一个非常适合放入文件夹/应用标志/设置类别的宏,但它仅适用于资源管理器中选择的当前项目。
当我在桌面上收到电子邮件警报并单击它打开电子邮件时,我希望能够针对该打开的项目运行相同的宏,但我找不到任何有关如何访问该对象的文档与我访问资源管理器列表中所选项目的方式类似。
我当前的选择逻辑如下:
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显然这是获取当前未清项目的代码:
Apparently this is the code to get the current open item:
我就是这样做的。将 Item 声明为 MailItem 而不是 Object,然后您可以从 IntelliSense 获得帮助。
I did it like this. Declare the Item as a MailItem instead of an Object and then you get help from IntelliSense.