Using the SMS and MMS Toolkit with ColdFusion

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 in ColdFusion 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 ColdFusion document

Create a new blank webdocument with the ".cfm" extention. First of all we are going to build the form whitch commands and properties of the device can be filled in. Then we are going to make a source code that connects to the device.

Step 3: Implementation

To use a GSM modem in ColdFusion, we need to use the Smsmessage object to create a new SMS message, and the SmsProtocolGsm object for communication through the GSM modem. A constants file might be usefull as well.

 <cfobject class="ActiveXperts.SmsProtocolGsm" type="com" name="objGsmProtocol" Action="Create"> 
 <cfobject class="ActiveXperts.SmsMessage" type="com" name="objSmsMessage" Action="Create"> 
 <cfobject class="ActiveXperts.SmsConstants" type="com" name="objConstants" Action="Create">

Step 4: Create a ColdFusion webform.

The following information is required to send a SMS message:

  • The port to which the GSM-Modem is connected.
  • The baudrate of the device. (You might get a tapi error if this isn't filled in correctly.)
  • The SIMcard's pincode. (If this is configured)
  • The recipient's telephonenumber.
  • The message.

Create a simple form to collect this information from the user. You can configure the required fields as required fields in ColdFusion. If the user does not fill in these fields properly, a messagebox is shown and the form will not be submitted. Make sure you create a ColdFusion form, not a plain HTML form.

A ColdFusion form which collects this information might look like this:

<cfform method="post">
<table class ="clbody" width="700">
       <td valign="top" width="110">Device:</td>
       <td valign="top" width="590">
          <cfselect name="CTL_DEVICES" style="width: 250px">
              <cfset arrDevices = getDevices() >
              <cfset intLength = ArrayLen(arrDevices) >
              <cfloop from="1" to=#intLength# index="i" step="1">
                 <cfset strDevice=arrDevices[#i#]>
                 <option value="#strDevice#">#strDevice#</option>

       <td valign="top">Speed:</td>
       <td valign="top">
          <cfselect name="CTL_SPEED" style="width: 250px">
              <cfset arrSpeed = getSpeeds() >
              <cfset intLength = ArrayLen(arrSpeed) >
              <cfloop from="1" to=#intLength# index="i" step="1">
                 <cfset strSpeed=arrSpeed[#i#]>
                 <option value="#strSpeed#">#strSpeed#</option>
          (only applies to direct ports, i.e. COM1, COM2, etc.)

      <td valign="top">Pincode:</td>
      <td valign="top"><cfinput style="width: 250px" type="text" name="CTL_PINCODE" value=""> (only required if SIM card has PIN code)</td>
      <td valign="top">Recipient:</td>
      <td valign="top"><cfinput style="width: 250px" type="text" name="CTL_RECIPIENT" value="" required="yes">  
            <a target="_blank" href="">Recipient number format</a></td>
      <td valign="top">Message:</td>
      <td valign="top"><cfinput style="width: 250px" type="text" name="CTL_MESSAGE" value="" required="yes"></td>
      <td valign="top">Unicode:</td>
      <td valign="top"><cfinput  type="checkbox" name="CTL_UNICODE" value="uni" checked> Unicode</td>
      <td valign="top"> </td>
      <td valign="top"><cfinput size="25" type="submit" value="Send" name="CTL_SEND" style="height: 23px; width: 250px"></td>
      <td valign="top"> </td>
      <td valign="top"> </td>
      <td valign="top">Result code:</td>
      <td valign="top">#numLastError#: #strLastError#</td>

To provide the comboxes in the form of correct information we're using the following functions:

<!--- Get the device speeds //--->
<cffunction name="getSpeeds">
    <cfset arrSpeeds = ArrayNew(1)>
    <cfset ArrayAppend(arrSpeeds, "Default")>
    <cfset ArrayAppend(arrSpeeds, "1200")>
    <cfset ArrayAppend(arrSpeeds, "2400")>
    <cfset ArrayAppend(arrSpeeds, "4800")>
    <cfset ArrayAppend(arrSpeeds, "9600")>
    <cfset ArrayAppend(arrSpeeds, "19200")>
    <cfset ArrayAppend(arrSpeeds, "38400")>
    <cfset ArrayAppend(arrSpeeds, "57600")>
    <cfset ArrayAppend(arrSpeeds, "115200")>
    <cfreturn arrSpeeds >

<!--- Get a list of connected devices //--->
<cffunction name="getDevices">
    <cfset intDevices = objGsm.GetDeviceCount() -1>
    <cfset arrDevices = ArrayNew(1)>
    <cfloop from="0" to=#intDevices# index="i">
        <cfset ArrayAppend(arrDevices, objGsm.GetDevice(#i#))>
    <cfreturn arrDevices>

Please keep in mind that the getDevices function might not work properly because your IUSR might not have the proper rights to list all devices connected to the server.

Step 5: Send the SMS

Whenever the user submits the form, all information should be available. The collected information now needs to be passed to the SMS and MMS Toolkit. First the message object is called. In this object the recipient number, the message itself and the body format are being configured.

Now the message is submitted to the GSM object. The GSM object sends the message. The GSM object needs to be configure first though. The devicename, the baudrate and the pincode are required to send the message. It might be useful to clear this object before performing any action at all. Perhaps earlier configured settings might be used by the toolkit.

To prevent errors caused by empty fields in the form, set the default values of these fields.

If everything is filled in properly the message can be sent.

A code which does all this might look like this:

<cfset numLastError = 0>
<cfset strLastError = "">
    <cfparam name="FORM.CTL_RECIPIENT" default="">
    <cfparam name="FORM.CTL_UNICODE" default="">
    <cfparam name="FORM.CTL_MESSAGE" default="">
    <cfparam name="FORM.CTL_DEVICES" default="">
    <cfparam name="FORM.CTL_SPEED" default="">
    <cfparam name="FORM.CTL_PINCODE" default="">
        objMessage.Recipient = FORM.CTL_RECIPIENT;
        if( FORM.CTL_UNICODE neq "" ){
            objMessage.Format = 20;
        objMessage.Data = FORM.CTL_MESSAGE;
        objGsm.Device = FORM.CTL_DEVICES;
        if( FORM.CTL_SPEED eq "Default" ){
            objGsm.DeviceSpeed = 0;
            objGsm.DeviceSpeed = FORM.CTL_SPEED;
        if( FORM.CTL_PINCODE neq "" ){
            objGsm.EnterPin( FORM.CTL_PINCODE );
        if( objGsm.LastError eq 0 ){
            objGsm.Send( objMessage );
        numLastError = objGsm.LastError;
        strLastError = objGsm.GetErrorDescription( numLastError );  

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