ActiveXperts SMS and MMS Toolkit Add SMS and MMS capabilities to any Windows or .NET application

Using The SMS and MMS Toolkit with ASP.NET (Visual Basic)

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 into ASP.NET projects.

Prerequisites

You must install and configre Internet Information Services (IIS) before using the SMS and MMS Toolkit with ASP .NET If you don't have IIS installed, use the following stpes:

  • From the Control Panel, click 'Add/Remove Programs'. Select the 'Add/Remove Windows Components' icon from the left pane, then select 'Application Server' and click on 'Details'. You can now select both 'ASP .NET' and 'Internet Information Services (IIS)'. Click 'OK' to continue installation;

  • Make sure that ASP .NET is allowed on the web server:

    GSM ASP.NET

    (Click on the picture to enlarge)

Step 1: Download and install the SMS and MMS Toolkit

Download the 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 ASP .NET VB Project

Launch Microsoft Visual Studio (for instance 'Microsoft Visual Studio 2005') from the Start menu. Choose 'New' from the 'File' menu and click on 'Web Site'. In the 'Web Site' dialog, select ASP .NET Web Site. Select a name for the application (for instance: 'DemoApp') and a name for the solution (for instance: 'DemoSolution'). Also, select the directory where you want to store the project (for instance: 'C:\MyProjects):

ASP.NET

(Click on the picture to enlarge)

Step 3: Refer to the SMS and MMS Toolkit Library

Now that a new project has been created, you must add a reference to the SMS and MMS Toolkit in the project to be able to use the the SMS and MMS Toolkit objects. To do so, choose 'Add Reference...' from the 'Project' menu. In the 'Add Reference' dialog that pops up, select the 'COM' tab and select the ActiveXperts SMS and MMS Toolkit Type Library' as shown in the following picture:

(Click on the picture to enlarge)

Click 'OK' to close the 'Add Reference' dialog.

Step 4: Declare and create the SMS and MMS Toolkit objects

On top of your code, type the following line to use the SMS and MMS Toolkit namespace:

Imports AXmsCtrl

In your Main function, declare and create the following object for GSM:

Dim objGsmProtocol As SmsProtocolGsm = New SmsProtocolGsm()

Create the SmsMessage object like this:

Dim objSmsMessage As SmsMessage = New SmsMessage()

Create the SmsConstants object like this:

Dim objSmsConstants As SmsConstants = New SmsConstants()

Step 5: Send and/or receive SMS messages

You can now send and/or receive SMS messages.

The following code shows how to send a SMS message through a connected GSM phone or modem:

Imports AXmsCtrl

Public Class WebForm1
    Inherits System.Web.UI.Page
    Protected WithEvents DropDownDevice As System.Web.UI.WebControls.DropDownList
    Protected WithEvents DropDownSpeed As System.Web.UI.WebControls.DropDownList
    Protected WithEvents TextRecipient As System.Web.UI.WebControls.TextBox
    Protected WithEvents TextMessage As System.Web.UI.WebControls.TextBox
    Protected WithEvents ButtonSend As System.Web.UI.WebControls.Button
    Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Public objGsmProtocol As SmsProtocolGsm
    Public objSmsMessage  As SmsMessage

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim i As System.Int16

        objGsmProtocol = New SmsProtocolGsm()
        objSmsMessage  = New SmsMessage()

        For i = 0 To objGsmProtocol.GetDeviceCount - 1
            DropDownDevice.Items.Add(objGsmProtocol.GetDevice(i))    ' Add Devices
        Next

        ' Add serial devices

        DropDownDevice.Items.Add("COM1")
        DropDownDevice.Items.Add("COM2")
        DropDownDevice.Items.Add("COM3")
        DropDownDevice.Items.Add("COM4")
        DropDownDevice.Items.Add("COM5")
        DropDownDevice.Items.Add("COM6")
        DropDownDevice.Items.Add("COM7")
        DropDownDevice.Items.Add("COM8")

        DropDownSpeed.Items.Add("Default")
        DropDownSpeed.Items.Add("1200")
        DropDownSpeed.Items.Add("2400")
        DropDownSpeed.Items.Add("4800")
        DropDownSpeed.Items.Add("9600")
        DropDownSpeed.Items.Add("19200")
        DropDownSpeed.Items.Add("38400")
        DropDownSpeed.Items.Add("57600")
        DropDownSpeed.Items.Add("115200")
    End Sub

    Private Sub ButtonSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSend.Click

        objGsmProtocol.Device = DropDownDevice.SelectedItem.Text.ToString()

        If DropDownSpeed.SelectedIndex = 0 Then
            objGsmProtocol.DeviceSpeed = 0       ' Default;
        Else
            objGsmProtocol.DeviceSpeed = System.Int32.Parse(DropDownSpeed.SelectedItem.Value.ToString())
        End If


        objSmsMessage.Recipient = TextRecipient.Text.ToString()
        objSmsMessage.Data = TextMessage.Text.ToString()

        objGsmProtocol.LogFile = "C:\SMSLog.txt"

        objGsmProtocol.Send( objSmsMessage )


        If objGsmProtocol.LastError = 0 Then

            Form1.InnerHtml = "<b><font size=" + Chr(34) + "2" + Chr(34) + " >"
            Form1.InnerHtml += "Your message was submitted successfully"
            Form1.InnerHtml += "<br>"
            Form1.InnerHtml += "<br>"
            Form1.InnerHtml += "Message Reference: " + objGsmProtocol.MessageReference.ToString()
            Form1.InnerHtml += "</font></b>"
        Else
            Form1.InnerHtml = "<b><font size=" + Chr(34) + "2" + Chr(34) + " color =\" + Chr(34) + "700000" + Chr(34) + ">"
            Form1.InnerHtml += "Failed to send message, ERROR#"
            Form1.InnerHtml += objGsmProtocol.LastError.ToString()
            Form1.InnerHtml += " : "
            Form1.InnerHtml += objGsmProtocol.GetErrorDescription(objGsmProtocol.LastError)
            Form1.InnerHtml += ".</font></b>"
        End If
    End Sub

End Class

There are many working samples included with the product. You can also find them on the ActiveXperts FTP site: ftp.activexperts-labs.com/samples/mobile-messaging-component.

NOTE: Demo Projects are created with Microsoft Visual Studio 2005

The SMS and MMS Toolkit project ships with a set of Microsoft Visual Studio .NET samples, including samples for Microsoft ASP .NET (Visual Basic). The projects are created with Microsoft Visual Studio 2005.

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.