Category.CategoryID Property (Outlook)

Office 2013 and later

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

Returns a String value that represents the unique identifier for the Category object. Read-only.

expression .CategoryID

expression A variable that represents a Category object.

Because the Name property of a Category object can be changed either programmatically or by user action, each Category object is uniquely identified by a globally unique identifier (GUID), assigned to the object, that can be retrieved using this property. The GUID is presented as a string using the following format:


The following Visual Basic for Applications (VBA) example displays a dialog box containing the names and identifiers for each Category object contained in the Categories collection associated with the default NameSpace object.

Private Sub ListCategoryIDs() 
 Dim objNameSpace As NameSpace 
 Dim objCategory As Category 
 Dim strOutput As String 
 ' Obtain a NameSpace object reference. 
 Set objNameSpace = Application.GetNamespace("MAPI") 
 ' Check if the Categories collection for the Namespace 
 ' contains one or more Category objects. 
 If objNameSpace.Categories.Count > 0 Then 
 ' Enumerate the Categories collection. 
 For Each objCategory In objNameSpace.Categories 
 ' Add the name and ID of the Category object to 
 ' the output string. 
 strOutput = strOutput & objCategory.Name & _ 
 ": " & objCategory.CategoryID & vbCrLf 
 End If 
 ' Display the output string. 
 MsgBox strOutput 
 ' Clean up. 
 Set objCategory = Nothing 
 Set objNameSpace = Nothing 
End Sub