A step-by-step guide on how to register store event sinksBefore you use regevent.vbs to register the event sink VB
script, you need to register a new COM+ application on the Exchange server to
properly execute script-based store events. Please follow the steps below:
- To start the Component Services console, click Start,
select Programs, Administrative Tools, and Component Services.
- In the Component Services snap-in, expand the list in the
following order: Component Services, Computers, and My Computer.
- Right-click COM+ Applications in the left pane, and select
New and Application.
- Click Next and then choose the "Create An Empty
Application" button.
- Enter ScriptEventSink as the name for the new
application.
- Confirm that the Server Application radio button is
selected and click Next.
- Click Next and click Finish.
- Select a user that will have owner permissions for the
application you are creating, or choose the current user by selecting
"Interactive User - The Current Logged On User" radio button.
Note If you choose Interactive User, make sure the account that you
are currently logged on with has one of the following permissions:
- Explicit "Full mailbox access" right on the mailbox you
plan to publish the sink to
- Explicit Allow for the "Receive As" right on the
mailbox store
- Open the newly created COM+ Application you just created,
right-click on the Components subfolder, and choose New and, then, select
Component.
- Click Next, then choose Install New
Component(s).
- Browse the file system and select
\Exchsrvr\Bin\exodbesh.dll. Click Next and Finish.
After registering the new COM+ application, you need to write
the event sink VB script file. Here is a sample event sink that does nothing
but log its' existence:
<SCRIPT LANGUAGE="VBScript">
Option Explicit
Public Sub ExStoreEvents_OnSave(pEventInfo, bstrURLItem, lFlags)
LogFile "ExStoreEvents_OnSave"
End Sub
public Sub ExStoreEvents_OnDelete(pEventInfo, bstrURLItem, lFlags)
LogFile "ExStoreEvents_OnDelete"
End Sub
Public Sub ExStoreEvents_OnSyncSave(pEventInfo, bstrURLItem, lFlags)
LogFile "ExStoreEvents_OnSyncSave"
End Sub
Public Sub ExStoreEvents_OnSyncDelete(pEventInfo, bstrURLItem, lFlags)
LogFile "ExStoreEvents_OnSyncDelete"
End Sub
public Sub LogFile(MyString)
Dim fso
Dim txtfile
Set fso = CreateObject("Scripting.FileSystemObject")
Set txtfile = fso.OpenTextFile("c:\LogFile.log", 8, True)
txtfile.WriteLine (MyString)
txtfile.Close
End Sub
</SCRIPT>
We assume that the sink is now saved in the testscript.vbs., you can now
register this event sink VB script using the following steps:
- Click Start, select Run, and type "cmd" (without the
quotation marks) to enter the command prompt.
- Change the directory to \Exchsrvr\Bin and type the
following 2 commands:
regsvr32 exodbesh.dll
regsvr32
exodbprx.dll - Copy the regevent.vbs (located in the \Program
Files\Exchange SDK\SDK\Support\OLEDB\Scripts directory.) and the event sink VB
script files onto the root of the C drive.
- Start the command prompt, and change to the directory of
C:\. Type the command to run the regevent.vbs. The following command is one
example:
cscript regevent.vbs add "onsave;ondelete"
ExOleDB.ScriptEventSink.1
"file://./backofficestorage/contoso.com/MBX/smith/inbox/testsink" -m deep -file
"c:\testscript.vbs"
Note This command is used to register the event sink VB script named
testscript.vbs in the Inbox of the mailbox named smith. In the command above,
you replace contoso.com with the default domain name referenced on the "Local
path" field in the Virtual Directory tab of the Exchange virtual directory
properties in the Internet Information Services snap-in.
How to delete store event sinksIf you want to delete the event sink you registered in a
particular mailbox, you can perform the following steps:
- Start the command prompt, and change to the directory where
the regevent.vbs is located.
- Type the command to run regevent.vbs. The following code is
one example of the command:
cscript regevent.vbs delete
"file://./backofficestorage/contoso.com/MBX/smith/inbox/testsink"
More examples of commands for event sink registrationsExample 1The above command example is to register a specific mailbox.
To register event sinks to a specific store with the regevent.vbs script, here
is an example:
cscript regevent.vbs add OnSyncSave test.sink
"file://./backofficestorage/contoso.com/MBX/SystemMailbox{9ADEA9EA-3924-401F-9C70-0
3B6B7378C9D}/StoreEvents/GlobalEvents/testsink" -m deep
In the above
command, the event sink is actually registered to the system mailbox named
SystemMailbox{GUID} in the mailbox store. To determine the GUID:
- In the Exchange System Manager, find the mailbox store that
you want to register the event sink to.
- Select the "Mailboxes" node under the mailbox store to see
the list of its' mailboxes. You will see a mailbox called
"SystemMailbox{GUID}." The GUID is the GUID you want.
Example 2The following example uses the RegEvent script to register an
OnSyncSave event to a mailbox:
cscript regevent.vbs add OnSyncSave
ExOleDB.ScriptEventSink.1
"file://./backofficestorage/contoso.com/user1/inbox/eventsink1" -m deep -file
"c:\script1.vbs"
Example 3The following example uses the regevent script to register an
OnSave and OnDelete event to the public folder named folder1 under the Public
Folders tree:
cscript regevent.vbs add "OnSave;OnDelete"
ExOleDB.ScriptEventSink.1 "file://./backofficestorage/contoso.com/Public
Folders/folder1/testsink" -m deep -file "c:\vbscript1.vbs"