title: C# to move mail to PST
body: <p>I want to use C# to access my Outlook Sent Folder and move the messages there to a folder in my PST called Archive.  This is the code I was working with, but I am getting multiple compile errors.  Does someone here with more coding experience know how to accomplish this?</p>
  
  <pre><code>static void MoveMe()
  {
  try
  {
      _app = new Microsoft.Office.Interop.Outlook.Application();
      _ns = _app.GetNamespace("MAPI");
      _ns.Logon(null, null, false, false);
      Application.ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox);
      Outlook.Items SentMailItems = SentMail.Items;
      Outlook.MailItem newEmail = null;
      foreach (object collectionItem in SentMailItems)
      {
          moveMail.Move(Archive);
      }
  }
  catch (System.Runtime.InteropServices.COMException ex)
  {
      Console.WriteLine(ex.ToString());
  }
  finally
  {
      _ns = null;
      _app = null;
      _inboxFolder = null;
  }
  }
  </code></pre>
  
  <p>Error list from the comments:</p>
  
  <ol>
  <li><code>Only assignment, call, increment, decrement, and new object expressions can be used as a statement</code></li>
  <li><code>The type or namespace name 'Emails' could not be found (are you missing a using directive or an assembly reference?)</code></li>
  <li><code>The name 'A_Sent' does not exist in the current context</code></li>
  <li><code>The name 'moveMail' does not exist in the current context</code></li>
  <li><code>The name 'SentMail' does not exist in the current context</code></li>
  </ol>