title: OpenSharedItem with Outlook interop throws odd exception with Office 2003, works with Office 2008
body: <p>I'm using the Office interop API to open a .msg file saved from outlook, and to then show a reply window to allow the user to reply to it.</p>
  
  <p>When running Office 2003, the OpenSharedItem(pathToMSGFile); call throws the following exception:</p>
  
  <pre><code>Unhandled Exception: System.AccessViolationException: Attempted to read or write
    protected memory. This is often an indication that other memory is corrupt.
    at Microsoft.Office.Interop.Outlook._NameSpace.OpenSharedItem(String Path)
    at OutlookTest.Program.Main(String[] args)
  </code></pre>
  
  <p>When running Office 2008, it works absolutely fine.</p>
  
  <p>I've put together a small test case, the code is as follows:</p>
  
  <pre><code>static void Main(string[] args)
  {
      try
      {
          Application app;
          string pathToMSGFile = "\\\\path\\to\\foobar.msg";
  
          if (args.Length &gt; 0)
          {
              pathToMSGFile = args[0];
          }
  
          if (!File.Exists(pathToMSGFile))
          {
              Console.WriteLine("{0} does not exist.", pathToMSGFile);
              return;
          }
  
          Console.WriteLine("Opening {0}", pathToMSGFile);
  
          Type olType = Type.GetTypeFromProgID("Outlook.Application", false);
  
          app = Activator.CreateInstance(olType) as Application;
  
          MailItem fld = (MailItem)app.Session.OpenSharedItem(pathToMSGFile);
  
          _MailItem reply = fld.ReplyAll();
          reply.Save();
          reply.Display(false);
  
          Console.ReadKey();
  
          reply.Close(OlInspectorClose.olDiscard);
      }
      catch (System.Exception ex)
      {
          Console.WriteLine(ex.ToString());
  
          if (ex.InnerException != null)
          {
              Console.WriteLine(ex.InnerException.ToString());
          }
      }
  
      Console.ReadKey();
  }
  </code></pre>
  
  <p>The application is targeted as .Net 4, using the Office12 interop library. Same happens regardless of whether its compiled for AnyCPU or x86.</p>