OUTBOX: Registering a VB Script Store Sink

The following is an exerpt from an email describing the steps to setup a VBS event sink on Exchange...

Before registering the event sink you need to install and configure a COM+ component which will execute the VB Script. This COM+ ships with Exchange and is used to execute any VB Script event sinks on the server. You will need to download the Exchange Server SDK to get regevent.vbs and eshmts.vbs which are discussed below.

 

You only need to do the following steps one time on the server...

 

1. Register the Script Host Component...
https://msdn.microsoft.com/library/default.asp?url=/library/en-us/e2k3/e2k3/_exch2k_the_script_host_sink.asp

 

2. When you setup the Script Host in COM+ you will specify a domain account and password for the COM+ component to run as. This account will need permissions to the mailboxes or folders that the sink will be registered to as well as local permissions to write to the log file. You can give permissions to individual user accounts through Active Directory Users and Computers (ADUC). In Exchange System Manager (ESM) you can give permissions organizational levels to provide broader access. Also this scripts sends out email, for this script to be able to send mail as another account you need to grant that permission on the account in ADUC.

 

3. Setup the Script Host in COM+...
https://msdn.microsoft.com/library/default.asp?url=/library/en-us/e2k3/e2k3/_exch2k_the_eshmts_script.asp

 

After setting up the Script Host, you will then register the script on each folder or mailbox that you want it to run. I usually create a batch file to add and remove a script while testing. You need to run your batch file as a user with write permissions to the mailbox or folder you are registering the script on.

 

Here is the command I used in my batch file...

cscript "C:\Program Files\Exchange SDK\SDK\Support\OLEDB\Scripts\RegEvent.vbs" Add OnSave ExOleDB.ScriptEventSink.1 "file://./backofficestorage/mstehle03.extest.microsoft.com/mbx/mrmet/inbox/scriptevent" -file "C:\files\code\EventSinks\ScriptSinks\OnSave.vbs"

This will create a registration item at the given file path. Notice that my script is creating a registration item called "scriptevent" in mrmet's Inbox. You will need to change the VBS file path and mailbox URL according to your environment.

 

...After following these steps there is no requirement for getting the VBS file on the file system as it is stored in the registration item itself. If you do a GET on the registration item you will see your VBS code...

 

...Another note Exchange Explorer can setup these registrations through a wizard but for VBS sinks it doesn't add the script to the registration item, rather it creates a seperate IPM.Document that is the script file. This is annoying because it isn't hidden and will appear in the folder when viewed in Outlook or OWA. Obviously deleting this file will break the sink...