title: How to add ItemAddEventHandler for multiple folders in outlook using C#?
body: <p>We have added some rules in outlook to move item to some folder depends on some condition.</p>
  <p>example: if email sender is xyz@gmail.com and subject contains particular keyword lets say &quot;news&quot; then move that email to folder &quot;NewsFolder&quot;, if email sender is prq@gmail.com then move that email to &quot;InterestFolder&quot; folder. etc.</p>
  <p>I want to perform some action when item is added to particular folder, I have added configuration in app.config for checking folder name. I tried with itemAdd event handler but I failed.</p>
  <p>below is my code.</p>
  <pre><code>Outlook.NameSpace outlookNameSpace;
  Outlook.MAPIFolder inbox;
  Outlook.Items items;
  
  Private void ThisAddIn_Startup(object sender, system.EventArgs e)
  {
             //configuration will come from app.config file
          
              string configuration=&quot;news,NewsFolder|interest,InterestFolder&quot;; //comma separated by keyword, folder name
              string[] conf = configuration.split('|');
              foreach(string singleConfiguartion in conf)
             {
                    string[] config = singleConfiguraiton.Split(','); 
                    string configFolderName= config[1].ToString(); //get folder name from configuration
                    Application.ActiveExplorer().CurrentFolder = inbox.Folders[configFolderName];
                    Outlook.MAPIFolder currentFolder = inbox.Folders[configFolderName];
                    items= currentFolder.Items;
                    items.ItemAdd+= new Outlook.ItemEvents_ItemAddEventHandler(ItemAddedEventHandler);
             }
      
  }    
  
  void ItemAddedEventHandler(Object item)
  {
  
  }
  </code></pre>
  <p>This way is worked if I want to add event handler for &quot;Inbox&quot; folder only. But I want to add Event handler for &quot;NewsFolder&quot; and &quot;InterestFolder&quot;.</p>