2017-03-07 59 views
1

任何一個人知道,如果有可能當用戶更改在Outlook 2016「發件人」地址下拉掛鉤到事件:展望事件:在變化「從地址」

enter image description here

據測試了一些VBA宏事件Application.ItemLoadApplication.ItemSend等。我已經得到了,但我希望有更多的事件,我可以掛接到。

回答

2

當然 - MailItem.PropertyChange事件將觸發:

PropertyChange ("SendUsingAccount") 
PropertyChange ("SentOnBehalfOfName") 

你可以看到現場活動中OutlookSpy - 打開新的項目,點擊OutlookSpy絲帶項目按鈕,轉到事件選項卡 - OutlookSpy將記錄他們被提出的事件。

2

MailItem類的PropertyChange事件在實例的顯式內置屬性(例如Subject)更改時觸發。請注意,一旦更改UI中的值,您可能不會立即觸發事件。在將焦點移至其他字段或保存項目之前,Outlook可能不會觸發事件。

0

爲了完整 - 這裏是完整的代碼,我已經實現了拍攝,我有興趣的事件

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