Removing an Event Registration for a Folder
Topic Last Modified: 2006-06-11
To remove an event sink, you delete the item, using code similar to the following sample:
Example
Visual Basic
'All you have to do is delete the registration item
Private Sub DeleteEvent(Server As String)
On Error Resume Next
'here is 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
' Clean up.
cn.Close
rEvent.Close
Set cn = Nothing
Set rEvent = Nothing
End Sub