Outlook Object Model : Creating Outlook Categories programmatically and assign colors, shortcut keys to that

In this blogpost, we will try to create the Outlook Categories programmatically using Outlook Object Model API. Also we will assign the relevant colors and shortcuts to that. Whenever we try with Outlook Object Model, it’s relatively simple.

'[Code snippet to create Categories]
Private Sub CreateCategory()
    Dim objNameSpace As NameSpace
    Dim objCategory As Category    
    ' Obtain a NameSpace object reference
    Set objNameSpace = Application.GetNamespace("MAPI")
    'Add the Category, set its color and shortcutkey, if any
    Set objCategory = objNameSpace.Categories.Add("SampleCat", OlCategoryColor.olCategoryColorDarkBlue, 
   ' Clean up
    Set objCategory = Nothing
    Set objNameSpace = Nothing
End Sub
Happy programming!!
Comments (1)
  1. NW says:

    This is extremely helpful – thank you for taking the time to post it!

Comments are closed.

Skip to main content