none
Return the color category assigned to an appointment. using Microsoft.Office.Interop.Outlook. RRS feed

  • Question

  • Hi,<o:p></o:p>

    I need to return the color category assigned to an appointment.<o:p></o:p>

    I am using Microsoft.Office.Interop.Outlook with c#<o:p></o:p>



    Mr Shaw

    Tuesday, November 11, 2014 11:27 AM

All replies

  • Hello,

    You can use the Categories property of the AppointmentItem class.

    See Print a list of Outlook Categories and their Colors

    Tuesday, November 11, 2014 12:29 PM
  • Thanks,

    The code which I am using only looks at the categories of my local outlook session. I need to be able to referrer to the categories of shared calendar.

    Here is my code.

     Microsoft.Office.Interop.Outlook.NameSpace oNaSp = outlook.GetNamespace("mapi");

     foreach (Microsoft.Office.Interop.Outlook.Category category in oNaSp.Categories)

     MessageBox.Show(category.Name.ToString());
    MessageBox.Show(category.Color.ToString());
    }

    I also need to return which appointment is associated with which color.

    Thanks for the help.


    Mr Shaw

    Tuesday, November 11, 2014 12:52 PM
  • The Name of the Category will be stored in the Categories string (see AppointmentItem.Categories).

    Since Outlook 2007, The Color Categories are stored within the main Calendar folder of the mailbox owner. Try using any low level property viewers (for example, MFCMAPI or OutlookSpy) for looking at hidden items in the folder.

    Tuesday, November 11, 2014 1:00 PM
  • Ok.. i now understand the relationship between AppointmentItem.Categories and Outlook.Category.

    It's a shame that you can get a list of catefogy names and colors of a sharedfolder using GetSharedDefaultFolder.


    Mr Shaw

    Tuesday, November 11, 2014 1:09 PM
  • The Outlook object model has a lot of known issues that move from version to version staying alive for years.
    Tuesday, November 11, 2014 1:36 PM
  • Read the property with the DASL name of "http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/82140003 using AppointmentItem.PropertyAccessor.GetProperty.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!


    Tuesday, November 11, 2014 5:03 PM
  • Thanks,

    I'll have to test the code tomorrow.

    I'll keep everybody posted.

    Ben :)


    Mr Shaw

    Tuesday, November 11, 2014 6:02 PM