How to Remotely Send a Message to a Group of Contacts
This sample demonstrates how to remotely send a message to a group of contacts. This can be useful when you need to send bulk SMS from a remote location (e.g. from your mobile phone or via email).
File ForwardMessage.vbs used in this sample is located in the folder:
C:\Program Files\CodeSegment\SMS Studio\Samples\InfoService
This script receives the pipe name, the ID of the account from which the messages should be sent and the text of the message. The first word of the message text
(separated with a space character from the rest of the text) should be the name of the group of recipients or the phone number of the single recipient. For example, a message text may contain
[Friends] Hello there!, assuming that you have a group named Friends in the Address Book.
The contents of the ForwardMessage.vbs file:
if WScript.Arguments.Count = 3 then
PipeName = WScript.Arguments(0)
AccountID = WScript.Arguments(1)
MsgText = Trim(WScript.Arguments(2))
if PipeName <> "" then
Pos = InStr(MsgText," ")
if Pos > 0 then
Recipient = Left(MsgText,Pos-1)
MsgText = Mid(MsgText,Pos)
MsgText = Replace(MsgText,vbCr,"%0D")
MsgText = Replace(MsgText,vbLf,"%0A")
set fso=CreateObject("Scripting.FileSystemObject")
set pipe=fso.CreateTextFile("\\.\pipe\" & PipeName)
pipe.WriteLine("AccountID:" & AccountID)
pipe.WriteLine("To:" & Recipient)
pipe.WriteLine("Encoded:" & MsgText)
pipe.WriteLine("<Send>")
pipe.Close
WScript.Quit(0)
else
WScript.Quit(1)
end if
else
MsgBox "Error: Pipe name is missing.", vbCritical, "SMS Studio Forward Message Sample"
WScript.Quit(1)
end if
else
MsgBox "Error: Wrong number of arguments.", vbCritical, "SMS Studio Forward 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: Forward Message
Pattern: *
Action: Execute external application
- In the Execute tab of the Add Rule dialog enter the following parameters:
External application: ForwardMessage.vbs - use the selection button ( ... ) to locate and select the external application.
Application parameters: "%PipeName%" "ACCOUNT_ID" "%MsgText%"
- Note that ACCOUNT_ID parameter should be taken from the Edit Connection dialog / Account tab / Account ID field.
- Click the Add button to close the Add Rule dialog.
- In the Advanced tab of the Info Setup dialog enter the name of the pipe:
Pipe name: RemotePipe
- 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 Text field (e.g. +1234567 Hello!
or [Friends] Hello!) and click the Receive button. The Info
service will receive this message and run the ForwardMessage.vbs application which will place outgoing messages in
the Outbox.
Related topics
Named Pipe