Implementing an OnSyncDelete Event Sink

Implementing an OnSyncDelete Event Sink

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 example handles the OnSyncDelete event. See Store Event Sink Bit Flags for more information.

Visual Basic

Private Sub IExStoreSyncEvents_OnSyncDelete(ByVal pEventInfo As Exoledb.IExStoreEventInfo, ByVal bstrURLItem As String, ByVal lFlags As Long)

    Dim FSO         As Object
    Dim EvtLog      As String
    Dim EvtFile

'Log file
    EvtLog = Environ("SystemDrive") & "\OnSyncDelete.log"

'Creates new log file %SystemDrive%\OnSyncDelete.log or opens it if exists
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set EvtFile = FSO.OpenTextFile(EvtLog, 8, True)

'Append incoming event info into log file
    EvtFile.WriteLine ("[VB Event Sink]          OnSyncDelete()")
    EvtFile.WriteLine ("  URL Item:              " & bstrURLItem)
    EvtFile.WriteLine ("  lFlags:                " & "0x" & Hex(lFlags))

'To determine type of incoming OnSyncDelete notifications:

    'Case 1: EVT_SYNC_BEGIN
    If lFlags And EVT_SYNC_BEGIN Then
        'Perform your tasks
        'Begin phase of OnSyncDelete
        EvtFile.WriteLine ("  Flag contains EVT_SYNC_BEGIN bit set")

    'Case 2: EVT_SYNC_COMMITTED
    ElseIf lFlags And EVT_SYNC_COMMITTED Then
        'Perform your tasks
        'Commit phase of OnSyncDelete
        EvtFile.WriteLine ("  Flag contains EVT_SYNC_COMMITTED bit set")

    'Case 3: EVT_SYNC_ABORTED
    ElseIf lFlags And EVT_SYNC_ABORTED Then
        'Perform your tasks
        'Abort phase of OnSyncDelete
        EvtFile.WriteLine ("  Flag contains EVT_SYNC_ABORTED bit set")

    End If

'To determine type of OnSyncDelete

    'EVT_SOFTDELETE
    If lFlags And EVT_SOFTDELETE Then
        'Perform your tasks
        EvtFile.WriteLine ("  Flag contains EVT_SOFTDELETE bit set")
    End If

    'EVT_HARDDELETE
    If lFlags And EVT_HARDDELETE Then
        'Perform your tasks
        EvtFile.WriteLine ("  Flag contains EVT_HARDDELETE bit set")
    End If

     'Check if it is a folder notification
    If lFlags And EVT_IS_COLLECTION Then
        'Perform your tasks
        'OnSyncDelete for a folder
        EvtFile.WriteLine ("  Flag contains EVT_IS_COLLECTION bit set")
    End If

    EvtFile.WriteBlankLines (1)

'Before Quit
    EvtFile.Close
    Set FSO = Nothing

End Sub

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.