title: how to Update All Outlook(2003) Folders using C#
body: <p>I have to update all the Outlook Folders from my application.
  Here is my code, but it doesn't work.</p>
  
  <pre><code>Outlook.Application app = null;
  Outlook.SyncObject _syncObj = null;
  
  while (OutlookNotFound)
  {
      i++;
      try
      {
          app = Marshal.GetActiveObject("Outlook.Application") as Outlook.Application;
          OutlookNotFound = false;
      }
      catch (System.Exception ex)
      {
          Thread.Sleep(1000);
      }
      finally
      {
          if (i &gt; 10)
          OutlookNotFound = false;
      }
  }
  
  if (!OutlookNotFound)
  {
      //app.Session.GetDefaultFolder(Outlook.OlDefaultFolders.);
      if (app != null)
      {
          for (Int32 j = 0; j &lt; app.Session.SyncObjects.Count; j++)
          {
              _syncObj = app.Session.SyncObjects[1];
              _syncObj.SyncEnd += 
                  new Outlook.SyncObjectEvents_SyncEndEventHandler(_syncObj_SyncEnd);
          }
  
          _syncObj.Start();
          //app.Session.SyncObjects.AppFolders.SyncEnd += 
          //    new Outlook.SyncObjectEvents_SyncEndEventHandler(AppFolders_SyncEnd);
          //app.Session.SyncObjects.AppFolders.Start();
  
          return true;
      }
      else
      {
          return false;
      }
  }
  </code></pre>