title: How to run Outlook using Process.Start("outlook.exe") and get the control back
body: <p>My C# program needs to launch Office Outlook and get the current "running outlook application".
  In order to do that I've implemented the following simple program (so if you want you can test it simply):</p>
  
  <pre><code>using Outlook = Microsoft.Office.Interop.Outlook;
  using System.Runtime.InteropServices;
  
  static void Main(string[] args)
  {
    Outlook.Application outlookObj = null;
  
    if (Process.GetProcessesByName("OUTLOOK").Count().Equals(0))
    {
      Process.Start("outlook.exe"); // MY PROGRAM STOPS HERE
    }
    var process = Process.GetProcessesByName("OUTLOOK").First();
    while (!process.HasExited)
    {
      try
      {
        outlookObj = (Outlook.Application)Marshal.GetActiveObject("Outlook.Application");
        break;
      }
      catch
      {
        outlookObj = null;
      }
      System.Threading.Thread.Sleep(10);
    }
  
    string result = (outlookObj== null)? "DOES NOT WORK" : "OK";
    Console.WriteLine(result);
    Console.ReadLine();
  }
  </code></pre>
  
  <p>My problem is that once Office Outlook starts running then my C# console application does not continue its job. After the <code>Process.Start("outlook.exe");</code> instruction is executed then I must click on Visual Studio GUI in order to restart the console application and finally read "OK" on my console application.</p>
  
  <p>How can I solve my problem?</p>