This is part of a larger project I'm working on, but for now Iβm just trying to find a way to get the senderβs email address each time a user clicks on an email item in the inbox and its contents (the actual body of the email message) is displayed in the adjacent panel .
I tried writing code inside the ItemLoad event handler procedure, but even the MSDN website says that the Item object passed as an argument is not initialized by its properties, so calling (Item as MailItem) .SenderEmailAddress will not work.
Can someone tell me how to do this? (I am using Outlook 2007)
Below, by the way, does not work:
public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { //this code runs applicationObject = (Outlook.Application)application; this.applicationObject.Startup += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_StartupEventHandler(applicationObject_Startup); } void applicationObject_Startup() { //this code runs this.applicationObject.Explorers.NewExplorer += new Microsoft.Office.Interop.Outlook.ExplorersEvents_NewExplorerEventHandler(Explorers_NewExplorer); } void Explorers_NewExplorer(Microsoft.Office.Interop.Outlook.Explorer Explorer) { //This code does not run Explorer.SelectionChange += new Microsoft.Office.Interop.Outlook.ExplorerEvents_10_SelectionChangeEventHandler(Explorer_SelectionChange); } void Explorer_SelectionChange() { //This code does not run //do something }
source share