ActiveXperts SMS Component


ASP sample - Send SMS text through an SMPP provider

The ActiveXperts SMS Component is a software development kit (SDK) to enhance an application or script with SMS or Pager functionality. SMS messages can be sent/received using a GSM modem, an SMPP provider or an HTTP compliant SMSC.


In this example we are going to create a classic ASP page named 'Default.asp' to send SMS messges. This demo project will ask the user to give a phone number and a message body in the web interface.

A subscription to an SMPP provider is required. For this demo you can send a limited number of messages through our own gateway.

Step 1: Download and install the ActiveXperts SMS Component

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

Step 2: Create a new Web Site

First, create a new directory on the IIS Server's file system. This directory will hold the ASP later on.

From the 'Start menu', click on 'Administrative Tools' and click on 'Internet Information Services (IIS) Manager'. Right-click on the 'Web Sites' container and choose 'New->Web Site':

SMS from ASP page

(Click on the picture to enlarge)

The 'Web Site Creation Wizard' is shown, guiding you thorugh the process of creating a new web site. Provide all necessary information:

  • Description - a friendly description of the new site;
  • IP / Port / Host Header - choose your preferred way to distinguish between other web sites on the server;
  • Path - select the directory that will store the ASP file(s);
  • Web Site Access Permissions - in the Web Site Access Permissions dialog, enable 'Read' and 'Run scripts (such as ASP)';

You're now able to write an ASP script to send or receive SMS messages.

Step 3: Create the ActiveXperts SMS Component SMPP objects in ASP

Create a new ASP script called DEFAULT.ASP in the directory that was created in Step2, using your favorite editor. On top of the ASP code, insert the following lines to declare and create the objects:

<object runat="server" progid="AxSms.Smpp"         id="objSmpp"></object>
<object runat="server" progid="AxSms.Message"   id="objSmsMessage"></object>
<object runat="server" progid="AxSms.Constants" id="objSmsConstants"></object>

Step 4: Test a small piece of ASP

Now, test if your new web site is working well with the ActiveXperts SMS Component using your browser. If you are using Microsoft Internet Explorer, it is recommended to disable friendly error message because this default setting doesn't show any ASP error message, making it hard to debug if there are any problems:

  • Choose' Internet Options' from the 'Tools' menu;
  • Select the 'Advanced' tab;
  • In the 'Browsing' folder, de-select the 'Show friendly HTTP error messages' option;
  • Click 'OK' to close the dialog.

Now, use the following piece of code in your DEFAULT.ASP page:

<object runat="server" progid="AxSms.Smpp"         id="objSmpp"></object>
<object runat="server" progid="AxSms.Message"   id="objSmsMessage"></object>
<object runat="server" progid="AxSms.Constants" id="objSmsConstants"></object>

    <title>SMS Component Demo</title>
     SMS Component version: <% = objSmpp.Version %><br>
     SMS Component License Status: <% = objSmpp.LicenseStatus %>

Step 5: Send SMS messages

SMS from ASP page

(Click on the picture to enlarge)

You can now send SMS messages using an SMPP provider. This example uses the ActiveXperts SMPP demo provider which allows you to send 10 messages for free.

This is the part of code that sends the SMS message using the data contained in the objSmsMessage:

objSmpp.SubmitSms objSmsMessage, iMultipart

Appendix: Full source code

Following you can find the full source code which is also included in the ActiveXperts SMS Component package.

<object runat="server" progid="AxSms.Smpp"       id="objSmpp"></object>
<object runat="server" progid="AxSms.Message"    id="objSmsMessage"></object>
<object runat="server" progid="AxSms.Constants"  id="objSmsConstants"></object>

  strResult = "n/a"
  strLastResponse = ""

  Set fso = CreateObject("Scripting.FileSystemObject")
  strLogfile = fso.GetSpecialFolder(2) & "\AxSms.Smpp.log"
  objSmpp.LogFile = strLogfile
  ' Windows default: "C:\Windows\Temp\AxSms.Smpp.log"

  Dim strAccount, strPassword
  GetSmsDemoAccountInfo strAccount, strPassword

  If(Request("btnSendMessage") <> "") Then
    objSmpp.Connect Request("txtServer"), Request("txtServerPort"), 5000

    If (objSmpp.LastError <> 0 ) Then
      strResult = objSmpp.LastError & ": " & objSmpp.GetErrorDescription(objSmpp.LastError)

      iSystemMode = objSmsConstants.SMPP_BIND_TRANSCEIVER
      iVersion = objSmsConstants.SMPP_VERSION_34
      objSmpp.Bind iSystemMode, 
                    iVersion, 0, 0, 

      If (objSmpp.LastError <> 0) Then
        strResult = objSmpp.LastError & ": " & objSmpp.GetErrorDescription(objSmpp.LastError)

        Dim iMultipart, strMessageReference
        bSearchDeliveryReport = true

        objSmsMessage.RequestDeliveryReport = true
        objSmsMessage.ToAddress = Request("txtToAddress")
        objSmsMessage.Body = Request("txtMessage")
        objSmsMessage.BodyFormat = objSmsConstants.BODYFORMAT_TEXT

        If (Request("cbxFlash") <> 0) Then
          objSmsMessage.DataCoding = objSmsMessage.DataCoding or objSmsConstants.DATACODING_FLASH
        End If

        If (Request("cbxMultipart") <> 0) Then
          iMultipart = objSmsConstants.MULTIPART_OK
          iMultipart = objSmsConstants.MULTIPART_TRUNCATE
        End IF

        objSmpp.SubmitSms objSmsMessage, iMultipart

        If (objSmpp.LastError <> 0) Then
          strResult = objSmpp.LastError & ": " & objSmpp.GetErrorDescription(objSmpp.LastError)
          Do While (objSmpp.WaitForSmsUpdate(1000))
             Set objMessage = objSmpp.FetchSmsUpdate()
            If (objSmpp.LastError = 0) Then
              objSmpp.Sleep 100
              exit do
            End If            
          strMessageReference = objMessage.Reference
          Do While (bSearchDeliveryReport)
            Set objMessage = objSmpp.ReceiveMessage()
            Do While (objsmpp.LastError = 0)
              If (objMessage.SmppIsDeliveryReport) Then

        If (strMessageReference = Mid(objMessage.Body, InStr(objMessage.Body, "id:") + 3, 8)) Then
          strMessageStatus = Mid(objMessage.Body, InStr(objMessage.Body, "stat:") + 5, 7)
          bSearchDeliveryReport = false                  
          Exit Do
        End If
              End If
              Set objMessage = objSmpp.ReceiveMessage()              
          strResult = objSmpp.LastError & ": " & objSmpp.GetErrorDescription(objSmpp.LastError)
        End If
      End If
    End If
  End If
  Function GetSmsDemoAccountInfo (strGwAccount, strGwPassword)
    ' NOTE: during installation of the ActiveXperts SMS Component, a unique login and password 
    ' is created for you. This login and password can be used to send a few SMS messages 
    ' through the gateway, for free. 
    ' The 'GetSmsDemoAccountInfo' reads the unique account info from a file that was created 
    ' during installation

    Set objShell = Server.CreateObject("")
    strDirectory = 
objShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\ActiveXperts\SMS Component\InstallRoot")
    strDirectory = strDirectory & "\Utilities\activexperts-labs.txt"
    Dim strAccount, strPassword

    Set objFileSystem = Server.CreateObject("Scripting.FileSystemObject")
    Set objFile = objFileSystem.OpenTextFile(strDirectory, 1, true)
    strGwAccount = objFile.ReadLine
    strGwPassword = objFile.ReadLine

  End Function

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

<html xmlns="" >
  <title>ActiveXperts SMS Component Demo</title>
  <link rel="Stylesheet" type="text/css" href="css/Layout.css" />
  <div class="ax_maincontainer">
    <div class="ax_header">
      <div class="ax_stroke"></div>
      <div class="ax_logo"></div>
    </div><!-- /header -->

    <div class="ax_container">
      <h1><b>SMS Component ASP SMPP Sample</b></h1>
      <hr />
      This demo allows you to send SMS messages over SMPP. If you don't have an SMPP subscription,
      you can use the ActiveXperts SMPP Demo Gateway. You can send out a few SMS messages
      for free through this gateway.<br />
      <form action="smpp.asp" method="post">
        <h2>SMS Component:</h2>
        <h3>Build: <% = objSmpp.Build %>; Module: <% = objSmpp.Module %></h3>

        <!-- Server -->
        <label for="Server">Server:</label>
          <input type="text" id="Server" name="txtServer" value="" />
          : <input type="text" name="txtServerPort" style="width: 75px;" value="2775" />

        <!-- System ID -->
        <label for="SystemID">System ID:</label>
          <input type="text" id="SystemID" name="txtSystemID" value="<% = strAccount %>" />

        <!-- Password -->
        <label for="Password">Password:</label>
          <input type="text" id="Password" name="txtPassword" value="<% = strPassword %>" />

        <!-- System Type -->
        <label for="SystemType">System Type:</label>
          <input type="text" id="SystemType" name="txtSystemType" value="SMPP" />

        <!-- Recipient -->
        <label for="ToAddress">Recipient:</label>
          <input type="text" id="ToAddress" name="txtToAddress" value="[ToAddress]" />

        <!-- Message, Multipart, Flash -->      
        <label for="Message">Message:</label>
          <textarea id="Message" name="txtMessage" style="height:45px;">
            Hello world send from ActiveXperts SMS Component!
          </textarea><br />

          <input type="checkbox"class="ax_cbFix" id="Multipart" name="cbxMultipart" value="1" />
          <label for="Multipart">Allow Multipart</label><br />

          <input type="checkbox"class="ax_cbFix" id="Flash" name="cbxFlash" value="1" />
          <label for="Flash">Flash</label>

        <!-- Send button -->
        <div class="ax_clearLabel"></div>
          <input type="submit" name="btnSendMessage" value="Send SMS Message!" />
        <!-- Empty row -->
        <div class="ax_clearRow"></div>

        <!-- Result -->
        <label for="Result"><b>Result:</b></label>
          <input type="text" id="Result" name="txtResult"class="ax_FullWidth" 
            style="font-weight: bold;" value="<% = strResult %>" />

        <!-- Message status -->
        <label for="Status">Message status:</label>
          <input type="text" id="Status" name="txtMessageStatus"class="ax_FullWidth" 
            value="<% = strMessageStatus %>" />
        <!-- Logfile -->
        <label for="Logfile">Logfile:</label>
          <input type="text" id="LogFile" name="txtLogFile"class="ax_FullWidth" 
            value="<% = strLogfile %>" />
      This demo uses the ActiveXperts SMS Component, an 
      <a href="" target="_blank">ActiveXperts Software</a> product.
      <br />
      <a href="Default.asp">Back to main page</a>
    </div><!-- /container -->


You can download the full source code of this project from the ActiveXperts FTP site: There are many other working samples included with the product or on the FTP site.

NOTE: Demo Projects are created with Microsoft Visual Studio 2008

The ActiveXperts SMS Component project ships with a set of Microsoft Visual Studio .NET samples. The projects are created with Microsoft Visual Studio 2008.

Users with a later version of Microsoft Visual Studio can open such a project. The Visual Studio Conversion Wizard will guide you through the process of converting the project to the version used.