This sample demonstrates how to save an incoming message into a text file using the Info service.
File SaveMessage.vbs used in this sample is located in the folder:
C:\Program Files\CodeSegment\SMS Studio\Samples\InfoService
This script receives the phone number of the sender, the text of the incoming message, and the name of the text file, and writes sender’s phone number and message text into the specified text file.
How to run this sample
Source code
The contents of the SaveMessage.vbs file:
'-------------------------------------------------------------------------------------------------------------------------------
' This script demonstrates how to save a message into a text file.
' WARNING: Error checking omitted for clarity.
'
' Use the following application parameters in the Info Rule dialog:
' "%MsgFrom%" "%MsgText%" "Messages.txt"
'-------------------------------------------------------------------------------------------------------------------------------
if WScript.Arguments.Count = 3 then
' Collect arguments
SenderPhone = WScript.Arguments(0) ' Sender phone
Text = WScript.Arguments(1) ' Message text
FileName = WScript.Arguments(2) ' File name
set fso = CreateObject("Scripting.FileSystemObject") ' Create file system object
set file = fso.OpenTextFile(FileName,8,true) ' Open file
file.Write(SenderPhone & "; " & Text & vbCrLf)
file.Close
WScript.Quit(0) ' Success
else
MsgBox "Error: Wrong number of arguments.", vbCritical, "SMS Studio Save Message Sample"
WScript.Quit(1) ' Error
end if
'-------------------------------------------------------------------------------------------------------------------------------
' Copyright (c) 2002-2009 CodeSegment. All rights reserved. http://www.codesegment.com/
'-------------------------------------------------------------------------------------------------------------------------------
| Copyright © 2002-2010 CodeSegment. All rights reserved. |