How to Save Incoming Messages into Text File
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.
The contents of the SaveMessage.vbs file:
if WScript.Arguments.Count = 3 then
SenderPhone = WScript.Arguments(0)
Text = WScript.Arguments(1)
FileName = WScript.Arguments(2)
set fso = CreateObject("Scripting.FileSystemObject")
set file = fso.OpenTextFile(FileName,8,true)
file.Write(SenderPhone & "; " & Text & vbCrLf)
file.Close
WScript.Quit(0)
else
MsgBox "Error: Wrong number of arguments.", vbCritical, "SMS Studio Save Message Sample"
WScript.Quit(1)
end if
How to run this sample
- Click the New button on the main toolbar and select the Info service option in the New Service dialog.
- Click the Setup button on the main toolbar to display the Info Setup dialog.
- In the General tab of the Info Setup dialog click the Add button to display the Add Rule dialog.
- In the General tab of the Add Rule dialog enter the following parameters:
Name: Save Message
Pattern: *
Action: Execute external application
- 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%" "Messages.txt"
- Click the Add button to close the Add Rule dialog.
- Click the OK button to close the Info Setup dialog.
- Click the Start
button on the main toolbar to start the Info service.
- 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 SaveMessage.vbs application which will save a message into Messages.txt
file.
Related topics
Named Pipe