HOWTO: Access Categories (Keywords) Field From an Event Script

ID: Q246516


The information in this article applies to:
  • Microsoft Exchange Server, version 5.5
  • Collaboration Data Objects (CDO), versions 1.2, 1.21


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:

Q201099 OL2000: Working with Keywords Fields from VBScript

Additional query words:

Keywords : kbCDO120 kbCDO121 kbXchge550 kbMsg kbVBp kbGrpMsg kbDSupport
Version : WINDOWS:1.2,1.21; winnt:5.5
Platform : WINDOWS winnt
Issue type : kbhowto


Last Reviewed: January 6, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.