NameSpace.Categories Property

Outlook Developer Reference

Returns or sets a Categories object that represents the set of Category objects available to the namespace. Read/write.

Version Information
 Version Added:  Outlook 2007

Syntax

expression.Categories

expression   A variable that represents a NameSpace object.

Remarks

This property represents the Master Category List, which is the set of Category objects that can be applied to Outlook items contained by the NameSpace object, and applies to all users of that namespace.

Example

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.

Visual Basic for Applications
  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
        Next
    End If
    
    ' Display the output string.
    MsgBox strOutput
    
    ' Clean up.
    Set objCategory = Nothing
    Set objNameSpace = Nothing
    
End Sub

See Also