Using The SMS and MMS Toolkit with VBScript (MM1 Connection)

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:

  • Send and receive numeric- and alphanumeric text SMS messages
  • Verify delivery of outgoing SMS messages
  • Support for multimedia SMS messages, including ringtones, pictures and logo's
  • Support for WAP Push, WAP Bookmarks, vCards, voicemail/e-mail/fax/MMS indications
  • Support for Unicode, to support foreign languages like Arabic, Chinese, Hebrew, etc.
  • Support for multi-part messages, to allow messages longer than 160 characters
  • Support for GSM modems, GSM phones, SMS/HTTP providers, SMPP (Short Message Peer to Peer) providers, TAP/XIO and UCP dial-in SMSC providers
  • Support Multi-threading environments. The component is thread-safe, which means it can be used in a multi-threaded environment
  • Samples included for various development platforms: MS Visual Basic, MS Visual Basic .NET, MS Visual C++, MS Visual Studio C# .NET, ASP, ASP .NET, Borland Delphi, Borland C++ Builder, Windows Powershell ColdFusion and more

MMS features:

  • Support for many multimedia formats incl.: JPG, GIF, PNG, BMP, WBMP, TIF, WAV, MP3, MIDI, AC3, GP3, AVI, MPG, MP4, VCARD, VCALENDAR, JAR and more
  • Support for MM1 (MMS over WAP), MM4 (MMS over SMTP) and MM7 (MMS over HTML/SOAP)

Pager features:

  • Send alpha-numeric Pager messages through SNPP

This document describes how the SMS and MMS Toolkit can be integrated into VBScript projects.

Step 1: Download and install The SMS and MMS Toolkit

Download the SMS and MMS Toolkit from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.

Step 2: Create a new script

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 MMS using MMS Toolkit.

Step 3: Create the SMS and MMS Toolkit objects in VBScript

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.

Now, declare the SMS and MMS Toolkit objects:

Dim objMm1Protocol
Dim objMmsMessage
Dim objMmsConstants
Dim objMmsSlide

Create the MMS objects like this:

Set objMm1Protocol   = CreateObject( "ActiveXperts.MmsProtocolMm1" )
Set objMmsMessage    = CreateObject( "ActiveXperts.MmsMessage" )
Set objMmsConstants  = CreateObject( "ActiveXperts.MmsConstants" )
Set objMmsSlide      = CreateObject( "ActiveXperts.MmsSlide" )

Now, add the following lines to the file to have your fist SMS and MMS Toolkit VBScript program:

WScript.Echo "Version: " & objMm1Protocol.Version
WScript.Echo "Expiration Date: " & objMm1Protocol.ExpirationDate

Step 4: Receive MMS messages

You can now receive MMS messages.

The following VBScript code shows how to receive MMS messages using a GSM/GPRS or UMTS phone or modem:

Option Explicit

' Declare objects
Dim objConstants, objMessage, objConnection, objSlide

' Declare variables
Dim n, nCount
Dim m, nAttachments

' Create objects
Set objConnection                 = CreateObject ( "ActiveXperts.MmsProtocolMm1" )
Set objConstants                  = CreateObject ( "ActiveXperts.MmsConstants" )

' Set 'Device'
objConnection.Device              = AskDevice( objConnection )
If( objConnection.Device = "" ) Then
   WScript.Echo "No TAPI devices available"
   WScript.Echo "Ready."
   WScript.Sleep 3000
End If

' Set 'LogFile'
objConnection.LogFile             = "c:\MmsLog.txt"

' Set provider properties GPRS APN, WAP Gateway and MMSC Server Address.
' Please check, or ask your provider for
' your provider's settings

' Set APN
objConnection.ProviderAPN         = ReadInput ( "Enter the providers Access Point Name (APN)", "", False )

' Set APN Account
objConnection.ProviderAPNAccount  = ReadInput ( "Enter the accountname associated with the APN (optional)", "", True )

' Set APN Password
objConnection.ProviderAPNPassword = ReadInput ( "Enter the password associated with the APN (optional)", "", True )

' Set WAP Gateway
objConnection.ProviderWAPGateway  = ReadInput ( "Enter the IP address of the WAP Gateway/Proxy", "", False )

objConnection.ProviderMMSC        = ReadInput ( "Enter the URL of the provider's MMSC", "", False )

' Download MMS notifications from SIM card
nCount = objConnection.CountReceivedMessages

WScript.Echo "CountReceivedMessages, result: " & objConnection.LastError & " (" & _ 
             objConnection.GetErrorDescription ( objConnection.LastError ) & ")"
If ( objConnection.LastError <> 0 ) Then
End If

If ( nCount = 0 ) Then
   WScript.Echo "No new messages waiting..."
   WScript.Sleep 3000
End If

' GPRS/UMTS: connect now
WScript.Echo "Connecting..."


WScript.Echo "Connect, result: " & objConnection.LastError & " (" & _ 
             objConnection.GetErrorDescription ( objConnection.LastError ) & ")"
If ( objConnection.LastError <> 0 ) Then
   WScript.Sleep 3000
End If

For n = 0 To nCount - 1
   On Error Resume Next
   Set objMessage = objConnection.GetMessage ( n )
   On Error Goto 0
   WScript.Echo "Get message, result: " & objConnection.LastError & " (" & _ 
             objConnection.GetErrorDescription ( objConnection.LastError ) & ")"
   If ( objConnection.LastError = 0 ) Then
         WScript.Echo "New MMS message received from: " & objMessage.From
         On Error Resume Next
         Set objSlide = objMessage.GetFirstSlide ()
         On Error Goto 0
         While ( objMessage.LastError = 0 ) 

            nAttachments = objSlide.CountAttachments ()
            For m = 0 To nAttachments - 1
               WScript.Echo "Attachment found: " & objSlide.GetAttachmentName ( m )
               objSlide.SaveAttachment m, "c:\temp\" & objSlide.GetAttachmentName ( m )
            On Error Resume Next
            Set objSlide = objMessage.GetNextSlide ()
            On Error Goto 0
   End If

' GPRS/UMTS Disconnect
WScript.Echo "Disconnected."

WScript.Echo "Ready."
WScript.Sleep 3000

' ***************************************************************************
' Function AskDevice
' ***************************************************************************
Function AskDevice( objDevice )
   Dim strMessage, strDevice, strDefaultDevice, i, n

   n              = objDevice.GetDeviceCount()
   If( n = 0 ) Then
     AskDevice = ""
     Exit Function
   End If
   strMessage     = "*** Enter one of the following device names *** " & vbCrLf & vbCrLf
   For i = 0 To n - 1
       strMessage = strMessage & objDevice.GetDevice( i )
       strMessage = strMessage & vbCrLf 

   If( n > 0 ) Then
       strDefaultDevice = objDevice.GetDevice( 0 )
       strDefaultDevice = ""
   End If
       strDevice = InputBox( strMessage, "Input", strDefaultDevice )
   Loop until strDevice <> ""

   AskDevice = strDevice
End Function

' ***************************************************************************
' Function ReadInput
' ***************************************************************************
Function ReadInput( ByVal strTitle, ByVal strDefault, ByVal bAllowEmpty )

  Dim strInput, strReturn

     strInput = inputbox( strTitle, "Enter value", strDefault )
     If ( strInput <> "" ) Then
          strReturn = strInput
     End If
  Loop until strReturn <> "" Or bAllowEmpty

  ReadInput = strReturn
End Function

There are many working samples included with the product. You can also find them on the ActiveXperts FTP site: