How to Forward Incoming Messages to External Application

This sample demonstrates how to forward incoming messages to external applications using the Info service.

File ShowMessage.vbs used in this sample is located in the folder:

    C:\Program Files\CodeSegment\SMS Studio\Samples\InfoService

This script receives the text and the phone number of the sender of the incoming message and displays a message box.

The contents of the ShowMessage.vbs file:

'-------------------------------------------------------------------------------------------------------------------------------
' This script demonstrates receiving parameters from the Info service
' by displaying a simple message box containing supplied arguments.
' WARNING: Error checking omitted for clarity.
'
' Use the following application parameters in the Info Rule dialog:
' "%MsgFromPhone%" "%MsgText%"
'-------------------------------------------------------------------------------------------------------------------------------

if WScript.Arguments.Count = 2 then
   
    ' Collect arguments
    SenderPhone = WScript.Arguments(0)      ' Sender phone
    Text = WScript.Arguments(1)             ' Message text
   
    MsgBox "From: " & SenderPhone & vbCr & "Text: " & Text, vbInformation, "SMS Studio Show Message Sample"
   
    WScript.Quit(0)                         ' Success
   
else
   
    MsgBox "Error: Wrong number of arguments.", vbCritical, "SMS Studio Show Message Sample"
    WScript.Quit(1)                         ' Error
   
end if

'-------------------------------------------------------------------------------------------------------------------------------
' Copyright (c) 2002-2006 CodeSegment. All rights reserved.                                          http://www.codesegment.com/
'-------------------------------------------------------------------------------------------------------------------------------

How to run this sample

  1. Click the New button on the main toolbar and select the Info service option in the New Service dialog.
  2. Click the Setup button on the main toolbar to display the Info Setup dialog.
  3. In the General tab of the Info Setup dialog click the Add button to display the Add Rule dialog.
  4. In the General tab of the Add Rule dialog enter the following parameters:
    Name: Show Message
    Pattern: *
    Action: Execute external application
  5. In the Execute tab of the Add Rule dialog enter the following parameters:
    External application: ShowMessage.vbs - use the selection button ( ... ) to locate and select the external application.
    Application parameters: "%MsgFromPhone%" "%MsgText%"
  6. Click the Add button to close the Add Rule dialog.
  7. Click the OK button to close the Info Setup dialog.
  8. Click the Start button on the main toolbar to start the Info service.
  9. Use Tools / Receive Message option in the main menu to display the Receive Message dialog. Fill in the Phone and Text fields and click the Receive button. The Info service will receive this message and run the ShowMessage.vbs application which will display a message box with the information about the received message.

Related topics

Named Pipe

 

Copyright © 2002-2007 CodeSegment. All rights reserved.

   www.codesegment.com