How do you get a reference to the mail item in the current open window in Outlook using VBA?

会有一股神秘感。 提交于 2019-11-29 13:44:07

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

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

I did it like this. Declare the Item as a MailItem instead of an Object and then you get help from IntelliSense.

Dim CurrentMessage As MailItem
Set CurrentMessage = ActiveInspector.CurrentItem
CurrentMessage.HTMLBody = "[Insert HTML here]" 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!