title: Restrict to list Folders under Inbox
body: <p>In here comes every folder details.Now I wanted to Restric it only list "Folders under Inbox"
  Actually now i wanted to list folders under inbox.(I created folders under inbox.I don't want to show Outbox,Draft &amp; so..on )</p>
  
  <p>MyCode.</p>
  
  <pre><code>private IEnumerable&lt;MAPIFolder&gt; GetAllFolders(Folders folders)
  {
      foreach (MAPIFolder f in folders) 
      {
          yield return f;
          foreach (var subfolder in GetAllFolders(f.Folders)) 
          {
              yield return subfolder;
          }
      }
  }
  </code></pre>
  
  <p>Button Click event</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      Microsoft.Office.Interop.Outlook.Application oApp  = 
          new Microsoft.Office.Interop.Outlook.Application();
      Microsoft.Office.Interop.Outlook._NameSpace ns = 
          (Microsoft.Office.Interop.Outlook._NameSpace)oApp.GetNamespace("MAPI"); 
      // in here i get the error "userd of unassign local variable".
      // without this line code works fine and return all the Folders &amp; 
      // Sub folders.
      Microsoft.Office.Interop.Outlook.MAPIFolder oPublicFolder = 
          olNS.GetDefaultFolder(
              Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
  
  
      foreach (var f in GetAllFolders(ns.Folders)) 
      {
          //if (f == oPublicFolder) continue;
          if (f.DefaultItemType == OlItemType.olMailItem) 
          {
              string ff = f.Name;
              //Some codings here
  
          }
      }
  
  }
  </code></pre>
  
  <p>This is sometimes a stupid question because sometimes it maybe a pretty simple.But here i ask you from helping hands.</p>