NameSpace.Categories Property (Outlook)

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

Version Added: Outlook 2007

expression .Categories

expression A variable that represents a NameSpace object.

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 
 

Community Additions

ADD
Show:
© 2014 Microsoft