How To Access Categories (Keywords) Field From an Event Script (246516)



The information in this article applies to:

  • Microsoft Exchange Server 5.5
  • Collaboration Data Objects (CDO) 1.2
  • Collaboration Data Objects (CDO) 1.21

This article was previously published under Q246516

SUMMARY

This article contains a code sample that demonstrates how to programmatically access the contents of a Message object's Categories field from within an Exchange Server Event Script.

MORE INFORMATION

The following Microsoft Visual Basic Scripting (VBScript) code is assumed to be installed on a folder on Microsoft Exchange Server 5.5 computer.
<SCRIPT RunAt=Server Language=VBScript>

Option Explicit

'This event is fired when a new message is added to the folder
Public Sub Folder_OnMessageCreated()
   Dim objMessage
   Set objMessage = EventDetails.Session.GetMessage(EventDetails.MessageID)
   Dim strCategories
   If TypeName(objMessage.Categories) = "Empty" Then
      strCategories = "No Categories!"
   Else
      strCategories = _
         "LBound:" & LBound(objMessage.Categories) & vbCrLf & _
         "UBound:" & UBound(objMessage.Categories) & vbCrLf & vbCrLf
      'Enumerating Categories in source message
      strCategories = strCategories & _
                      "Enumerating Categories in source message" & _
                      vbCrLf & vbCrLf
      Dim vCat
      Dim v
      vCat = objMessage.Categories
      For Each v In vCat
         strCategories = strCategories & v & vbCrLf
      Next
   End If
   Script.Response = strCategories
End Sub

</SCRIPT>
				

REFERENCES

See the following article to get information on how to programmatically access the contents of keywords fields (for example, categories, companies, and children fields) in Microsoft Outlook using VBScript:

201099 OL2000: Working with Keywords Fields from VBScript


Modification Type:MinorLast Reviewed:6/29/2004
Keywords:kbhowto kbMsg KB246516