Platform SDK: Exchange Server |
To provide a concrete example of the power of event scripting, we describe an example scenario: a company wants to automate the flow of information regarding employee requests for reimbursement to the appropriate people using Exchange Server. This way, when an employee wants to request some form of reimbursement, she fills out and submits the request simply by sending an e-mail message to the corresponding email address. The routing path would take the message to the requester's supervisor, to a person in Accounts Payable, and finally back to the requester, with payment notification. However, the company would also like to verify the requests before they are actually forwarded, including making sure all the necessary information was provided in the request, notifying the employee if the reimbursement amount is too high to be processed using this particular system, and so on. In each case, certain actions could then be taken, such as notifying the sender of any errors in the request or sending the request to certain people depending on its content. This process is easy to implement with Exchange 5.5 Event scripting. The following is a step-by-step outline of the process.
The Message Arrives
The employee submits an expense report by mailing or posting it to a designated "Expense Report" folder. Its arrival in the folder (known as the "application" folder) triggers the Folder_OnMessageCreated event.
The Event Service registered to monitor the folder then creates an instance of the registered agent, in this case the Exchange Scripting Agent, and submits the event to the agent.
Message is Processed
The agent or handler is notified of the event by the Event Service, and the corresponding function is executed. In this case, the Folder_OnMessageCreated subroutine in the script evaluates the properties contained in the expense report and verifies that all the required ones are present. If any are missing, it returns the report to the sender and stops. If all properties are present, it then compares reimbursement request amount to the expense authorization budget limit and forwards the report to the manager's manager if the limit would be exceeded. Otherwise, it forwards the request to the employee's manager and someone in Accounts Payable.
Timer is Set for Manager Response
An OnTimer event is defined in the script that will trigger if no response has arrived from the requester's manager after a specified number of days. It could notify the requester (or the manager's manager) of the delay and suggest another alternative action should be taken. In VBScript, this event could be handled with a Folder_OnTimer subroutine.