title: Getting the source of an event in the Outlook Object Model
body: <p>I am developing an Outlook plugin and am stuck on how to get the source object of an event in the call back method.</p>
  <p>I isolated my problem in the example code down below.</p>
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Windows.Forms;
  using Outlook = Microsoft.Office.Interop.Outlook;
  
  namespace Bug_Test
  {
      public partial class ThisAddIn
      {
  
          private static List&lt;Outlook.ItemEvents_10_Event&gt; gObj_itemEvtList = new List&lt;Outlook.ItemEvents_10_Event&gt;();
  
          private void ThisAddIn_Startup(object sender, System.EventArgs e)
          {
              // Get the application and explorer objects...
              Outlook.Application application = this.Application;
  
              application.ItemLoad += new Outlook.ApplicationEvents_11_ItemLoadEventHandler(onItemLoad);
          }
  
          private void onItemLoad(object Item)
          {
              Outlook.ItemEvents_10_Event gObj_itemEvt = (Outlook.ItemEvents_10_Event)Item;
  
              gObj_itemEvt.Reply += new Outlook.ItemEvents_10_ReplyEventHandler(on_Reply);
  
              gObj_itemEvtList.Add(gObj_itemEvt);
          }
  
          private void on_Reply(object Item, ref bool cancel)
          {
              Outlook.MailItem origin = Event.getSource() ;// mail on which the reply-event occured
              Outlook.MailItem newMail = (Outlook.MailItem) Item;
          }
  
          private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
          {
              // Hinweis: Outlook löst dieses Ereignis nicht mehr aus. Wenn Code vorhanden ist, der 
              //    muss ausgeführt werden, wenn Outlook heruntergefahren wird. Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?LinkId=506785.
          }
  
          #region Von VSTO generierter Code
  
          /// &lt;summary&gt;
          /// Erforderliche Methode für die Designerunterstützung.
          /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
          /// &lt;/summary&gt;
          private void InternalStartup()
          {
              this.Startup += new System.EventHandler(ThisAddIn_Startup);
              this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
          }
          
          #endregion
      }
  }
  </code></pre>
  <p>I the method called <code>on_Reply</code> I want to capture the source object (in Outlooks Object model case it will be one of the Outlook mail items) of the actual reply event. In the first line of the methode I am using the made up &quot;Event.getSource()&quot; method to better describe what I want to do.</p>
  <p>Is there a way to achieve this?</p>
  <p>Thank you and best wishes,
  Stefan</p>