Adding an Event Registration for a Folder
Adding an Event Registration for a Folder
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
The following code creates a store item, sets its content class and schema, and saves it to the store. The store then processes the event registration. For more information, see Event Registration.
Visual Basic
'==============================================================================' ' This subroutine creates the event binding in the meta-database ' by setting properties in an event registration item and committing it to the ' store. The event of saving the item triggers the event registration ' event sink, which processes the event registration and sets the registration ' to hidden so that it does not appear in the store folder. '==============================================================================' Sub AddNewStoreEvent(Server As String) On Error GoTo Errorhandler 'heres a list of the properties you can set for the registration event item 'not all of these are used in this example Const propcontentclass = "DAV: contentclass" Const propCriteria = "https://schemas.microsoft.com/exchange/events/Criteria" Const propEnabled = "https://schemas.microsoft.com/exchange/events/Enabled" Const propEventMethod = "https://schemas.microsoft.com/exchange/events/EventMethod" Const propMatchScope = "https://schemas.microsoft.com/exchange/events/MatchScope" Const propPriority = "https://schemas.microsoft.com/exchange/events/Priority" Const propScriptURL = "https://schemas.microsoft.com/exchange/events/ScriptUrl" Const propSinkClass = "https://schemas.microsoft.com/exchange/events/SinkClass" Const propTimerExpiryTime = "https://schemas.microsoft.com/exchange/events/TimerExpiryTime" Const propTimerInterval = "https://schemas.microsoft.com/exchange/events/TimerInterval" Const propTimerStartTime = "https://schemas.microsoft.com/exchange/events/TimerStartTime" Dim cn As New ADODB.Connection Dim rEvent As New ADODB.Record Dim strGuid Dim strBaseUrl Dim strEvent 'This will serve as the scope as well '(Where you save it is where the event fires) strBaseUrl = "file://./backofficestorage/" + _ Server + _ "/public folders/internet newsgroups" strEvent = strBaseUrl + "/evtreg1" 'evtreg1 is the item name ' Create the connection cn.Provider = "exoledb.datasource" cn.ConnectionString = strBaseUrl cn.Open cn.BeginTrans rEvent.Open strEvent, cn, 3, 0 ' adModeReadWrite, adCreateNonCollection 'set the properties in the item With rEvent.Fields .Item(propcontentclass) = "urn:content-class:storeeventreg" .Item(propEventMethod) = "onsave;ondelete" 'register for both save and delete events .Item(propSinkClass) = "VB_OutProc.sink" 'your registered event handler sink class ProgID 'match scope .Item(propMatchScope) = "deep" .Item(propCriteria) = "WHERE $DAV:ishidden$ = FALSE" 'Add custom properties which the event sink can use to 'determine the context of this event registration Const customnamespace = "mycustomnamespace:eventsinks/notifyingevents/" Dim propname As String propname = customnamespace + "caseswitch" .Append propname, adInteger, , , 2 'for a case switch in the event sink propname = customnamespace + "notifygroup" .Append propname, adChar, , , "Marketing" 'a group you've created in exchange MsgBox "New Event Binding with custom properties created." .Update 'get the ADO object current End With cn.CommitTrans 'commit transaction to the store GoTo Ending Errorhandler: ' Implement custom error handling here. Debug.Print "Error: " + Str(Err.Number) + " " + Err.Description Err.Clear Ending: ' Clean up. cn.Close rEvent.Close Set cn = Nothing Set rEvent = Nothing End Sub
During the process of adding an event registration for a folder, contextual information about this specific registration is also added. You can access this information from within the event sink. For more information, see Contextual Information in an Event Registration.
Send us your feedback about the Microsoft Exchange Server 2003 SDK.
Build: June 2007 (2007.618.1)
© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.