我使用这样的代码来捕获电子邮件中的打开事件,但这只会在您实际双击电子邮件时触发。有没有办法在预览窗格中打开电子邮件时运行代码?
Public WithEvents myItem As Outlook.MailItem
Public EventsDisable As Boolean
Private Sub Application_ItemLoad(ByVal Item As Object)
If EventsDisable = True Then Exit Sub
If Item.Class = olMail Then
Set myItem = Item
End If
End Sub
Private Sub myItem_Open(Cancel As Boolean)
EventsDisable = True
'do something
EventsDisable = False
End Sub
感谢。
答案 0 :(得分:1)
这将是Explorer.SelectionChange事件:https://msdn.microsoft.com/en-us/vba/outlook-vba/articles/explorer-selectionchange-event-outlook。