Categories Property (Message Object)

The Categories property specifies the categories assigned to the message. Read/write.

Syntax

objMessage.Categories

Data Type

String array

Remarks

The contents of the Categories property are defined by the application. Categories is commonly used to hold a set of keywords that can be used to access messages in a folder.

AppointmentItem objects in a Microsoft® Schedule+ calendar folder do not have the full set of attributes of a general message. If you obtain the default calendar folder by passing CdoDefaultFolderCalendar to the Session object's GetDefaultFolder method, its appointments have no defined value for the Categories property. An attempt to access Categories in this case returns CdoE_NO_SUPPORT.

When you declare a variable to interact with the Categories property, you must Dimension it as a String array, not just as an array of unspecified data type:

Dim KWords(10) As String ' NOT just Dim KWords(10) 
 

Note When you access an element of the Categories array, whether to read it or write it, you must include an extra set of parentheses to satisfy the Visual Basic compiler's allowance for a property parameter:

objMessage.Categories()(3) = "Third category" 
  ' ... 
  Kwords(i) = objMessage.Categories()(i) 
 

For more information on property parameters, see Property Parameters.

Example

This code fragment sets the Categories property of a message from a string array of keywords and later displays the categories:

Dim objMessage As Message 
' assume objMessage is valid and already being accessed 
Dim KWords(10) As String ' NOT just Dim KWords(10) 
' obtain up to ten keywords from user 
objMessage.Categories = KWords ' whole array; no index or parameter 
' ... later, read the message and examine its properties ... 
MsgBox "Categories for this message are:" 
For i = 1 To 10 
  If 0 < Len(objMessage.Categories()(i)) Then 
    MsgBox vbCrLf & objMessage.Categories()(i) 
  End If 
Next i