Share via


Removing an Event Registration for a Folder

Removing 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.

To remove an event sink, you delete the item, using code similar to the following sample:

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

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.