Conversation.SetAlwaysAssignCategories Method (Outlook)

Applies one or more categories to all existing items and future items of the conversation.

Version Information

Version Added: Outlook 2010

Syntax

expression .SetAlwaysAssignCategories(Categories, Store)

expression A variable that represents a Conversation object.

Parameters

Name

Required/Optional

Data Type

Description

Categories

Required

String

A comma-delimited string of one or more category names that are always assigned to all items in the conversation.

Store

Required

Store

The store in which items of the conversation should always be assigned the categories specified by the Categories parameter.

Remarks

If the store specified by the Store parameter represents a non-delivery store such as an archive .pst store, the method returns a string of categories that are applied to conversation items in the default delivery store.

The ItemChange event of the Items object occurs when you call the SetAlwaysAssignCategories method on a conversation.

To determine existing master categories for the current user, examine the Categories property of the Store object that is specified by the Store parameter. If one or more categories specified by the Categories parameter do not exist in the master categories collection, the categories will be assigned to the conversation but will not be added to the master categories collection.

To determine the existing categories that are always assigned to items of the conversation in the specified store, use the GetAlwaysAssignCategories method.

If SetAlwaysAssignCategories is called more than once, the result is cumulative. For example, if you call SetAlwaysAssignCategories specifying the category “Important” and then call SetAlwaysAssignCategories again specifying the categories "Business" and "Social", the categories that are always assigned are "Important", "Business", and "Social".

To stop the action of always assigning categories, use the ClearAlwaysAssignCategories method. After the ClearAlwaysAssignCategories method has been called, GetAlwaysAssignCategories returns an empty string.

The SetAlwaysAssignToCategories method ignores any category names that are empty strings. For example, if the Categories parameter is set to the string "Work,,Play", "Work" and "Play" are assigned to the conversation and the empty string category is ignored.

Example

The following Visual Basic for Applications (VBA) example shows how to assign categories to all existing and new items that arrive in the conversation of a specific mail item. The code example, DemoSetAlwaysAssignCategories, chooses the first mail item displayed in the Reading Pane as the specific mail item. DemoSetAlwaysAssignCategories verifies that conversations are enabled in the store for the selected mail item, obtains the conversation object for that mail item if a conversation exists, and uses SetAlwaysAssignToCategories to set the two categories "Best Practices" and "OOM" to all existing items and future items of that conversation.

Sub DemoSetAlwaysAssignCategories() 
 Dim oMail As Outlook.MailItem 
 Dim oConv As Outlook.Conversation 
 Dim oStore As Outlook.Store 
 ' Get the item displayed in the Reading Pane. 
 Set oMail = ActiveExplorer.Selection(1) 
 Set oStore = oMail.Parent.Store 
 If oStore.IsConversationEnabled Then 
 Set oConv = oMail.GetConversation 
 If Not (oConv Is Nothing) Then 
 Dim oFolder As Outlook.folder 
 oConv.SetAlwaysAssignCategories "Best Practices; OOM", oStore 
 End If 
 End If 
End Sub

See Also

Concepts

Conversation Object

Conversation Object Members