有谁知道当用户更改 Outlook 2016 中的“发件人”地址下拉列表时是否可以挂钩事件:
我已经为事件等测试了一些 VBA 宏,Application.ItemLoad
但Application.ItemSend
我希望有更多的事件可以挂钩。
有谁知道当用户更改 Outlook 2016 中的“发件人”地址下拉列表时是否可以挂钩事件:
我已经为事件等测试了一些 VBA 宏,Application.ItemLoad
但Application.ItemSend
我希望有更多的事件可以挂钩。
当实例的显式内置属性(例如,Subject)发生更改时,会触发 MailItem 类的PropertyChange事件。请注意,一旦更改 UI 中的值,您可能不会立即触发事件。在焦点移到另一个字段或保存项目之前,Outlook 可能不会触发事件。
当然 -MailItem.PropertyChange
事件会触发:
PropertyChange ("SendUsingAccount")
PropertyChange ("SentOnBehalfOfName")
您可以在OutlookSpy中查看实时事件- 打开新项目,单击 OutlookSpy 功能区上的项目按钮,转到“事件”选项卡 - OutlookSpy 将记录引发的事件。
为了完整性 - 这是我为捕获我感兴趣的事件而实现的完整代码。
Dim WithEvents myInspector As Outlook.Inspectors
Dim WithEvents myMailItem As Outlook.MailItem
Private Sub Application_Startup()
Set myInspector = Application.Inspectors
End Sub
Private Sub myInspector_NewInspector(ByVal Inspector As Outlook.Inspector)
If TypeOf Inspector.CurrentItem Is MailItem Then
Set myMailItem = Inspector.CurrentItem
End If
End Sub
Private Sub myMailItem_PropertyChange(ByVal Name As String)
' Properties we are interested in: "SendUsingAccount" / "SentOnBehalfOfName"
' Both get fired when the 'From' field is changed/re-selected
' So we are only going to trigger on one event or we will call the code twice
If Name = "SentOnBehalfOfName" Then
MsgBox myMailItem.SentOnBehalfOfName
End If
End Sub