none
Adding categories to a users master category list in Exchange 2010 using EWS. RRS feed

  • Question

  • Hello,

     

    Is there a way to add a Category to the Master category list in Exchange 2010 using Exchange Web Services.

    I found this blog entry on using CDO to add a category on Exchange 2007 and I wonder if there is a similar approach I could use to do the same on Exchange 2010 with EWS.

     

    All the best,

     

    Sam Jones.

    Wednesday, September 15, 2010 2:43 PM

Answers

  • Yes in 2010 you can use a UserConfiguration operation if you want to read the categoies have a look at David's sample in http://social.technet.microsoft.com/Forums/en/exchangesvrdevelopment/thread/e5c5f072-0b5c-49ce-9db7-57f76f5e011e. If you want to create a new category you can us something like

          Folder Root = Folder.Bind(service, WellKnownFolderName.Calendar);
          UserConfiguration UsrConfig = UserConfiguration.Bind(service, "CategoryList", WellKnownFolderName.Calendar, UserConfigurationProperties.All);
          System.IO.MemoryStream stream = new System.IO.MemoryStream(UsrConfig.XmlData);   
          var reader = new StreamReader(stream);
          MasterCategoryList MasterCatList = MasterCategoryList.Load(reader);
          foreach (Category cat in MasterCatList.Categories) {
            Console.WriteLine(cat.Name);
            Console.WriteLine(cat.Color);
          }
          Category newcat = new Category();
          newcat.Color = CategoryColor.DarkPeach;
          newcat.Name = "A new Entry 13";
          newcat.Id = Guid.NewGuid();
          MasterCatList.Categories.Add(newcat);
          System.IO.MemoryStream OutStream = new MemoryStream();
          StreamWriter Outvar = new StreamWriter(OutStream);
          MasterCatList.Save(Outvar);
          UsrConfig.XmlData = OutStream.ToArray();
          UsrConfig.Update();
    
    

    Cheers
    Glen

    • Marked as answer by SamMJones Thursday, September 16, 2010 2:13 PM
    Wednesday, September 15, 2010 10:33 PM

All replies

  • Yes in 2010 you can use a UserConfiguration operation if you want to read the categoies have a look at David's sample in http://social.technet.microsoft.com/Forums/en/exchangesvrdevelopment/thread/e5c5f072-0b5c-49ce-9db7-57f76f5e011e. If you want to create a new category you can us something like

          Folder Root = Folder.Bind(service, WellKnownFolderName.Calendar);
          UserConfiguration UsrConfig = UserConfiguration.Bind(service, "CategoryList", WellKnownFolderName.Calendar, UserConfigurationProperties.All);
          System.IO.MemoryStream stream = new System.IO.MemoryStream(UsrConfig.XmlData);   
          var reader = new StreamReader(stream);
          MasterCategoryList MasterCatList = MasterCategoryList.Load(reader);
          foreach (Category cat in MasterCatList.Categories) {
            Console.WriteLine(cat.Name);
            Console.WriteLine(cat.Color);
          }
          Category newcat = new Category();
          newcat.Color = CategoryColor.DarkPeach;
          newcat.Name = "A new Entry 13";
          newcat.Id = Guid.NewGuid();
          MasterCatList.Categories.Add(newcat);
          System.IO.MemoryStream OutStream = new MemoryStream();
          StreamWriter Outvar = new StreamWriter(OutStream);
          MasterCatList.Save(Outvar);
          UsrConfig.XmlData = OutStream.ToArray();
          UsrConfig.Update();
    
    

    Cheers
    Glen

    • Marked as answer by SamMJones Thursday, September 16, 2010 2:13 PM
    Wednesday, September 15, 2010 10:33 PM
  • Thanks, that helped alot.

    Sam,

    Thursday, September 16, 2010 2:14 PM
  • Hi Sam,  

      Can you please tell me how to create    MasterCategoryList for adding the categories. I appreciate your help. 

    Wednesday, February 20, 2013 2:15 PM
  • Shiva,

    If you are not a programmer you can use this tool.


    Thanks, John

    Wednesday, August 7, 2013 3:44 PM