Platform SDK: Exchange 2000 Server

Implementing an OnSave Event Sink

[This is preliminary documentation and subject to change.]

[Visual Basic]
Private Sub IExStoreAsyncEvents_OnSave(ByVal pEventInfo As Exoledb.IExStoreEventInfo, ByVal bstrURLItem As String, ByVal lFlags As Long)
    
    Dim fso As Object
    Dim WinTmpFile As String
    Dim OnSaveFile
    Dim Msg_Str As String
    Dim DispInfo As IExStoreDispEventInfo
    Dim Rec As Record
    
'log file
    
    WinTmpFile = Environ("SystemDrive") & "\SinkLogs\VBOnSave.log"
     
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set OnSaveFile = fso.OpenTextFile(WinTmpFile, 2, True)
           
    Set DispInfo = pEventInfo
    Set Rec = DispInfo.EventRecord
    
'File ops.
    OnSaveFile.WriteLine ("[VB Event Sink]        OnSave()")
    OnSaveFile.WriteLine ("  URL Src  Item:       " & bstrURLItem)
    OnSaveFile.WriteLine ("  Flags:               " & "0x" & Hex(lFlags))
   
    Msg_Str = Rec.Fields("DAV:displayname").Value
    OnSaveFile.WriteLine ("  DAV:displayname        " & Msg_Str)
   
    OnSaveFile.WriteBlankLines (1)
    OnSaveFile.Close
    
'Use the sink context (custom contextual info saved in the registration item)
    Dim case_switch As Integer
    Dim notify_group As String
    
    Const customnamespace = "mycustomnamespace:eventsinks/notifyingevents/"
    Dim propname As String
    
    propname = cust_namespace + "caseswitch"
    case_switch = Rec.Fields(propname)
    
    propname = cust_namespace + "notifygroup"
    notify_group = Rec.Fields(propname)

    'call some program to which uses the custom data to notify people of an event
    Dim r
    r = handle_notifyevent(case_switch, notify_group)
    
    
    
    Set fso = Nothing
    Set DispInfo = Nothing
End Sub