Platform SDK: Exchange 2000 Server

Removing an Event Sink Binding for a Folder

[This is preliminary documentation and subject to change.]

To remove an event sink you delete the item.

[Visual Basic]
  'All you have to do is delete the registration item
Private Sub DeleteEvent(Server As String)
    On Error Resume Next
   
    'heres a handy list of the properties you can set for the registration event item
    'not all of these are used in this example
   
    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
    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
    If Err.Number <> 0 Then
      MsgBox "Error Opening Connection : " & Err.Number & " " & Err.Description & vbCrLf
      Exit Sub
    End If
    
    cn.BeginTrans
    
    rEvent.Open strEvent, cn, 3, 0     ' adModeReadWrite, adCreateNonCollection
    If Err.Number <> 0 Then
      MsgBox "Error Opening Record : " & Err.Number & " " & Err.Description & vbCrLf
      Exit Sub
    End If
    
    rEvent.DeleteRecord
    
    cn.CommitTrans  'commit transaction to the store
    
    If Err.Number <> 0 Then
      MsgBox "Error Commiting Transaction : " & Err.Number & " " & Err.Description & vbCrLf
      Exit Sub
    End If

  
End Sub