NameSpace.Categories Property (Outlook)
Published: July 16, 2012
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.
This property is similar to the Categories property of the Store object. If there are multiple accounts defined in the current profile, use the Categories property of the store that is associated with the specific account.
The following Visual Basic for Applications (VBA) example displays a dialog box that contains the names and identifiers for each Category object that is 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 whether 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