title: Tracking eMails in Outlook 2007
body: <p>Greetings Overflowers,</p>
  
  <p>I am trying to develop a VSTO/C# corporate email tracker for specially signed emails.
  I am relying on:</p>
  
  <ol>
  <li>Inspectors.NewInspector</li>
  <li>Inspector.Close</li>
  <li>Inspector.Activate</li>
  <li>Inspector.Deactivate</li>
  </ol>
  
  <p>Somehow, the Inspector events stop firing after sometime.
  I register 2, 3 and 4 in the body of 1 after checking for the sign.
  I tried to keep track of already registered inspectors but no hope.
  Any clue ?</p>
  
  <p><strong>UPDATE:</strong> Here is a sample code. The evens OnSelect and OnOpen fires few times and then stops suddenly:</p>
  
  <pre><code>using System;
  using System.Collections;
  using Microsoft.Office.Interop.Outlook;
  // using Microsoft.Office.Core;
  
  namespace eMailTrackingSystem
  {
      public enum TrackingEvent
      {
          Opened, Closed, Forwarded, Deleted
      }
  
      public partial class eMTSAddIn
      {
          private ArrayList trackedEmails = new ArrayList();
  
          private void InternalStartup()
          {
              this.Application.ActiveExplorer().SelectionChange += new ExplorerEvents_10_SelectionChangeEventHandler(OnSelect);
          }
  
          private void OnSelect()
          {
              Selection selection = this.Application.ActiveExplorer().Selection;
  
              foreach (object item in selection)
              {
                  if (item is MailItem)
                  {
                      MailItem email = (MailItem)item;
  
                      if (email.Subject == "eMTS" &amp;&amp; !trackedEmails.Contains(email.EntryID))
                      {
                          email.Open += new ItemEvents_10_OpenEventHandler(OnOpen);
  
                          trackedEmails.Add(email.EntryID);
                      }
                  }
              }
          }
  
          private void OnOpen(ref bool cancel)
          {
          }
  
          private void OnClose()
          {
          }
      }
  }
  </code></pre>
  
  <p>Regards</p>