Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How to register a store event sink using Regevent.vbs on Exchange


View products that this article applies to.

Summary

This article describes:
  • The step-by-step guide on how to register store event sinks
  • The steps on how to delete store event sinks
  • More examples of commands used for event sink registrations

Note Besides using regevent.vbs to register an event sink, there are also other methods to register event sinks. For example, a developer can complie the codes into .dll files, and then register these .dll files directly on the Exchange server. This article introduces one method of registering event sinks when using regevent.vbs.

↑ Back to the top


More information

A step-by-step guide on how to register store event sinks
Before 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:
  1. To start the Component Services console, click Start, select Programs, Administrative Tools, and Component Services.
  2. In the Component Services snap-in, expand the list in the following order: Component Services, Computers, and My Computer.
  3. Right-click COM+ Applications in the left pane, and select New and Application.
  4. Click Next and then choose the "Create An Empty Application" button.
  5. Enter ScriptEventSink as the name for the new application.
  6. Confirm that the Server Application radio button is selected and click Next.
  7. Click Next and click Finish.
  8. 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
  9. Open the newly created COM+ Application you just created, right-click on the Components subfolder, and choose New and, then, select Component.
  10. Click Next, then choose Install New Component(s).
  11. 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:
  1. Click Start, select Run, and type "cmd" (without the quotation marks) to enter the command prompt.
  2. Change the directory to \Exchsrvr\Bin and type the following 2 commands:

    regsvr32 exodbesh.dll
    regsvr32 exodbprx.dll
  3. 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.
  4. 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 sinks

If you want to delete the event sink you registered in a particular mailbox, you can perform the following steps:
  1. Start the command prompt, and change to the directory where the regevent.vbs is located.
  2. 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 registrations

Example 1
The 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:
  1. In the Exchange System Manager, find the mailbox store that you want to register the event sink to.
  2. 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 2
The 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 3
The 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"

↑ Back to the top


References

Exchange SDK Development Tool:
http://msdn2.microsoft.com/en-us/library/ms980307.aspx

Microsoft Exchange Server 2003 Software Development Kit:
http://msdn2.microsoft.com/en-us/library/aa123692.aspx

Getting Well-Known Mailbox Folder URLs:
http://msdn2.microsoft.com/en-us/library/ms992623.aspx

↑ Back to the top


Keywords: KB895239, kbinfo, kbhowto

↑ Back to the top

Article Info
Article ID : 895239
Revision : 5
Created on : 10/25/2007
Published on : 10/25/2007
Exists online : False
Views : 283