BankPost Files

This sample application includes only a single file, the BankPost script. This script, called BankPost.txt, is provided here. You can use it in the installation of this sample application, described in Installing the BankPost Agent:

<SCRIPT RunAt=Server Language=VBScript>

'THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT 
'WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, 
'INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
'OF MERCHANTABILITY AND/OR FITNESS FOR A  PARTICULAR 
'PURPOSE

'---------------------------------------------------------------------
' FILE DESCRIPTION: Bank update sample for Exchange Scripting Agent
'
' FileName: BankPost.Txt
'
' Copyright (c) Microsoft Corporation 1993-1997. All rights reserved.
'---------------------------------------------------------------------

Option Explicit 

'---------------------------------------------------------------------
' Global Variables
'---------------------------------------------------------------------

    Dim g_bstrDebug

'---------------------------------------------------------------------
' Event Handlers
'---------------------------------------------------------------------

' DESCRIPTION: This event is fired when a new message is added to the folder
Public Sub Folder_OnMessageCreated

    on error resume next

    Dim oBank         'Bank Object
    Dim oMsg          'Message Object
    Dim Item          'Item Object

    Dim bstrPrimeAcct 'Account Number String
    Dim bstrAmount    'Account Number Amount
    Dim bstrTempVar   'Temp Variable String
 
    Dim varRes           'Result Variant
    
    'Get the incomming message object    
    Set oMsg = EventDetails.Session.GetMessage(EventDetails.MessageID, Null )
    Call DebugAppend("Get Message",True)

    'Get Bank Object and Msg Information
    set oBank = CreateObject("Bank.Account.VC")
    bstrPrimeAcct= oMsg.Subject
    bstrAmount = oMsg.Text

    'Post to the account
    varRes = oBank.Post(Clng(bstrPrimeAcct),Clng(bstrAmount),CStr(bstrTempVar))
    Call DebugAppend("oBank.Post",True)
    
    'Display Results
    if varRes = 0 then
        Call DebugAppend("OK: " & bstrAmount & " posted to bank account " & bstrPrimeAcct,False)

    else
        Call DebugAppend("ERR: Manager role required for amounts over $500.",False)
    end  if

    Call DebugAppend("Script",True)  'Trap any error and show info
    script.response = g_bstrDebug
        
End Sub

' DESCRIPTION: This event is fired when a message in the folder is changed
Public Sub Message_OnChange
   'Not Used
End Sub

' DESCRIPTION: This event is fired when a message is deleted from the folder
Public Sub Folder_OnMessageDeleted
   'Not Used
End Sub

' DESCRIPTION: This event is fired when the timer on the folder expires
Public Sub Folder_OnTimer
   'Not Used
End Sub

'-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
'                  PRIVATE FUNCTIONS/SUBS
'-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

'---------------------------------------------------------------------
'   Name: DebugAppend
'   Area: Debug
'   Desc: Simple Debugging Function
'   Parm: String Text, Bool ErrorFlag
'---------------------------------------------------------------------

Private Sub DebugAppend(bstrParm,boolErrChkFlag)

   if boolErrChkFlag = True then
       if err.number <> 0 then
           g_bstrDebug = g_bstrDebug & bstrParm & " Failed: " & cstr(err.number) & err.description & vbCrLf
           err.clear
       end if
   else
       g_bstrDebug = g_bstrDebug & bstrParm & vbCrLf
   end if

End Sub

</SCRIPT>