You are here:
ActiveXperts.com > SMS and MMS Toolkit > How to Use the SMS and MMS Toolkit > GSM phone or modem > VBScript
Quicklinks
The SMS and MMS Toolkit is a software development kit (SDK) to enhance an application or script with SMS, MMS and Pager functionality. SMS messages can be sent using a GSM/GPRS modem, an SMPP provider, an HTTP compliant SMS provider or using a standard dialup or fixed-line SMS modem. MMS messages can be sent via a GSM/GPRS modem (MM1), an SMTP server (MM4) or an XML/SOAP compliant provider (MM7).
SMS features:
MMS features:
Pager features:
This document describes how the SMS and MMS Toolkit can be integrated into VBScript projects.
Download the SMS and MMS Toolkit from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.
Create a new script using your favorite editor. You can simply use notepad. However, a VBScript editor is recommended, so you can browse through objects, objects properties and object functions.
You're now able to write a more advanced VBScript script to send/receive SMS using SMS and MMS Toolkit.
Create a new VBScript file called DEMO.VBS. It is recommended to insert the following line on top of your code:
Option Explicit
This statement requires that all variable names be defined (with the Dim statement), to avoid simple typos that can cause incredible headaches and long debugging sessions for something that should have never happened.
Insert the following line to declare and create the GSM object:
Set objGsmProtocol = CreateObject( "ActiveXperts.SmsProtocolGsm" )
Insert the following line to declare and create the SmsMessage object:
Set objSmsMessage = CreateObject( "ActiveXperts.SmsMessage" )
Insert the following line to declare and create the SmsConstants object:
Set objSmsConstants = CreateObject( "ActiveXperts.SmsConstants" )
Now, add the following lines to the file to have your fist SMS and MMS Toolkit VBScript program:
WScript.Echo "Version: " & objGsmProtocol.Version WScript.Echo "Expiration Date: " & objGsmProtocol.ExpirationDate
You can now send and/or receive SMS messages.
The following VBScript code shows how to send a SMS message using a connected GSM phone or modem:
Option Explicit
Dim objGsmProtocol
Dim nNumDevices, strDevices, i
Dim strReference
Set objGsmProtocol = CreateObject( "ActiveXperts.SmsProtocolGsm" )
Set objSmsMessage = CreateObject( "ActiveXperts.SmsMessage" )
Wscript.Echo "ActiveXperts SMS and MMS Toolkit " & objGsmProtocol.Version & " demo."
Wscript.Echo "Expiration date: " & objGsmProtocol.ExpirationDate & vbCrLf
nNumDevices = objGsmProtocol.GetDeviceCount()
strDevices = "*** Enter one of the following device names *** " & vbCrLf & vbCrLf
For i = 0 To nNumDevices-1
strDevices = strDevices & objGsmProtocol.GetDevice( i )
strDevices = strDevices & vbCrLf
Next
strDevices = strDevices & "COM1" & vbCrLf & "COM2" & vbCrLf & "COM ..." & vbCrLf
' Set Device
Do
objGsmProtocol.Device = inputbox( strDevices, "Input" )
Loop until objGsmProtocol.Device <> ""
' Set recipient
Do
objSmsMessage.Recipient = inputbox( "Enter the recipients phone number." & vbCrLf & "( Use international number format. )", "Input" )
Loop until objSmsMessage.Recipient <> ""
' Set message text
Do
objSmsMessage.Data = inputbox( "Enter the message text you want to send to the recipient.", "Input" )
Loop until objSmsMessage.Data <> ""
' Set Logfile
objGsmProtocol.LogFile = "c:\SmsLog.txt"
' Set Status Report on/off
'objSmsMessage.RequestDeliveryStatus = TRUE
' Use GSM provider's validity period ( Can be specified in minutes )
objSmsMessage.ValidityPeriod = 0
' Enter PinCode ( optional )
' objGsmProtocol.EnterPin ( "1234" )
' Send the message
WScript.Echo "Sending the message..."
strReference = objGsmProtocol.Send objSmsMessage
' Show the result
If( objGsmProtocol.LastError <> 0 ) Then
WScript.Echo "Failed to send the message, error: " & objGsmProtocol.LastError & " (" & objGsmProtocol.GetErrorDescription( objGsmProtocol.LastError ) & ")"
WScript.Echo "To view the trace file, open " & objGsmProtocol.LogFile & "."
Else
WScript.Echo "Message successfully submitted ( MessageReference = " & strReference & " )"
End If
There are many working samples included with the product. You can also find them on the ActiveXperts FTP site: ftp.activexperts-labs.com/samples/xmstoolkit.