ユーザーが Outlook 2016 で「差出人」アドレス ドロップダウンを変更したときに、イベントにフックできるかどうかは誰にもわかりません。
Application.ItemLoadイベントなどのためにいくつかの VBA マクロをテストするところまでは行きましApplication.ItemSendたが、フックできるイベントが他にもあることを望んでいました。
ユーザーが Outlook 2016 で「差出人」アドレス ドロップダウンを変更したときに、イベントにフックできるかどうかは誰にもわかりません。
Application.ItemLoadイベントなどのためにいくつかの VBA マクロをテストするところまでは行きましApplication.ItemSendたが、フックできるイベントが他にもあることを望んでいました。
完全を期すために、関心のあるイベントをキャプチャするために実装した完全なコードを次に示します。
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