Conversation.SetAlwaysAssignCategories (Outlook)

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

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.

SetAlwaysAssignCategories (Categories, Store)


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

Arguments

The following arguments are required:

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

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