title: Delete Emails from Outlook Folder Using C#
body: <p>I can't seem to get this working. I am trying to iterate through all the mail items in a folder I created named 'SlaughterPDFs' and delete the emails. </p>
  
  <p>Below is the code I am using. In this code I was just trying to delete the mail items out of the outlook 'Drafts' folder. </p>
  
  <pre><code>public void deleteMails()
  {
      Application tempApp = new Application();
      MAPIFolder tempInbox = default(MAPIFolder);
      Items JunkItems = default(Items);
  
      tempInbox = tempApp.GetNamespace("MAPI").
          GetDefaultFolder(OlDefaultFolders.olFolderDrafts);
      JunkItems = tempInbox.Items;
      MailItem DeleteMail = default(MailItem);
      foreach (object newMail_loopVariable in JunkItems)
      {
          DeleteMail = (MailItem)newMail_loopVariable;
          DeleteMail.Delete();
      }
      JunkItems = null;
      tempInbox = null;
      tempApp = null;
  }
  </code></pre>
  
  <p>Anyone have any idea what I am doing wrong? Or should I be moving these emails to a new folder. </p>