Exchange Server Scripting Agent Sample Script

Bank Post      (BANKPOST.TXT)

This sample script illustrates calling Microsoft Transaction
Server (MTS) objects from within an Exchange Server script. At
first glance, this example looks unexceptional  its just calling
a normal COM object (Bank.Account.VC). But thats the whole idea
behind Microsoft Transaction Server: applications dont have to
change to participate in business transactions. Transactions can
be encapsulated inside regular COM objects, and called from
scripts or other programs.

This particular example uses the sample transaction objects that
are provided with MTS. When a new message is received in the
folder, the script runs and interprets the Subject and Body field
of the mail message as the Bank Account # and Amount of the
transaction, respectively. The Post method of the Bank.Account
object is called, using that Account # and Amount.

A single line in a VB script program:

     Res = oBank.Post(PrimeAcct, Amount, TempVar)

can cause a complex database transaction to be performed in SQL
Server, including automatic transaction rollback if an error
occurs. MTS effectively hides such complexity from the script
programmer.

EXTERNAL REQUIREMENT:

This sample requires that you have installed and configured the
sample Bank application that is supplied with Microsoft
Transaction Server. MTS 2.0 is recommended, which is available as
part of the Microsoft Windows NT 4.0 Option Pack  along with IIS
4.0. The sample bank application also requires an ODBC-compatible
database to host the application, such as SQL Server 6.5. Please
see the documentation for installing and configuring the MTS
Sample applications before proceeding.

INSTALLING THE SAMPLE:

1.   Make sure that Event Service is installed and running on your
     Exchange Server.

2.   Ensure that you have given yourself permission to install &
     run scripts on this server. See the "Microsoft Exchange Server
     Getting Started Guide" for further information.

3.   Open the "BANKPOST.TXT" file using Notepad. Select all of the
     text, and copy it to the clipboard.

4.   From Microsoft Outlook 8.03, select or create a Public Folder
     or Mailbox Inbox folder that will contain the Bank Post messages.
     You must have Owner permissions on this folder.

5.   Right-click on the folder, and choose Properties. Click the
     Agents tab.

6.   Create a new agent. Click the Edit button to edit its
     properties.

7.   Enable the checkboxes for the following events:
        [x] A new item is posted in this folder

8.   Click Edit Script. A blank script skeleton is shown.

9.   Select all of the text in the script. Paste the contents of
     the clipboard (BANKPOST.TXT), replacing the previous script
     contents. Click OK and save the agent.

TESTING THE SAMPLE:

Send or post a message to the folder. Make sure the subject field
contains the bank account number (ie: 1 is the number used for the
default bank sample), and the message body contains the amount of
money, and nothing else (ie: 400). This number should be an
integer value.

You can verify whether the money is actually posted to the bank
account by using the VB Bank Client sample application (supplied
with MTS) to view the current status of any of the bank accounts.

SETTING THE MANAGERS ROLE:

MTS allows for the use of declarative, role-based security. The
Post method of the Bank.Account object contains logic that limits
transactions > $500 to only those NT accounts listed for the
MANAGERS role. This script displays an error message in the event
viewer if the amount is > $500, unless the NT account under which
the Exchange Script Agent is listed in the MANAGERS role for this
MTS package.  By default, the script engine will be running under
the Exchange Service Account.

To add this account to the MANAGERS role for the bank sample, go
into Transaction Server Explorer. Under My Computer/Packages
Installed/Sample Bank/Roles/Managers/Users; right click and add
the Exchange Service Account.

NOTES:

The script calls the Visual C++ version of the Bank.Account object
(Bank.Account.VC), but it could just as easily use the VB or Java
version of the object, since all three versions are provided with
the MTS samples.

This example uses an MTS object that performs a transaction
against a SQL Server database. At this time, it is not possible
for an Exchange Server 5.5 database to participate in such a
transaction. This functionality may be provided in future releases
of Exchange Server.





