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

Using The SMS and MMS Toolkit with Visual Basic 5.x/6.x

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 Visual Basic 5.x/6.x 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 Visual Basic project

Launch 'Microsoft Visual Basic' from the Start menu, and choose 'New' from the 'File Menu'. The 'New Project' dialog appears.
Select 'Standard Exe' and click 'OK':

Visual Basic

(Click on the picture to enlarge)

Step 3: Refer to the SMS Messaging Server Library

A new Project is created, with a blank form.

First, you must add a reference to SMS Messaging Server in the project to be able to use the SMS objects. To do so, choose 'References...' from the 'Project' menu. In the 'References' dialog that pops up, enable the ActiveXperts SMS and MMS Toolkit Type Library' reference as shown in the following picture:

Visual Basic

(Click on the picture to enlarge)

Click 'OK' to close the 'References...' dialog.

Step 4: Declare and create the objects

Then, select the Project form and choose 'View Code' from the context menu:

Visual Basic

(Click on the picture to enlarge)

On top of your code, declare the following objects for SMS/HTTP:

Dim objHttpProtocol  As AXmsCtrl.SmsProtocolHttp
Dim objSmsMessage    As AXmsCtrl.SmsMessage
Dim objSmsConstants  As AXmsCtrl.SmsConstants

From the Code window, select 'Form'. The Private Sub 'Form_Load()' will be displayed now.

In the 'Form Load' function, create the HTTP objects in the following way:

Set objHttpProtocol  = CreateObject("ActiveXperts.SmsProtocolHttp")
Set objSmsMessage    = CreateObject("ActiveXperts.SmsMessage")
Set objSmsConstants  = CreateObject("ActiveXperts.SmsConstants")

Step 5: Send an SMS messages

The following code shows how to send an SMS message through an HTTP based SMS provider:

Option Explicit

Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Const MAX_PATH = 260

Private objHttpProtocol As AXmsCtrl.SmsProtocolHttp
Private objSmsMessage   As AXmsCtrl.SmsMessage
Private objSmsConstants As AXmsCtrl.SmsConstants

Private Sub CommandSend_Click()
    ' Clear all properties
    objHttpProtocol.Clear
    objSmsMessage.Clear
    
    ' Set Logfile
    objHttpProtocol.LogFile = TextLogFile.Text
    
    ' Set provider properties
    objHttpProtocol.ProviderHost            = TextHostname.Text
    objHttpProtocol.ProviderPort            = CInt(TextHostport.Text)
    objHttpProtocol.ProviderSuccessResponse = TextSuccessResponse.Text
    
    ' Set URL Template
    objHttpProtocol.URLText = TextURL.Text
    
    ' Set Message Data
    objSmsMessage.Sender    = TextSender.Text
    objSmsMessage.Recipient = TextRecipient.Text
    objSmsMessage.Data      = TextMessage.Text
    objSmsMessage.Format    = objSmsConstants.asMESSAGEFORMAT_TEXT
    
    ' Send the message
    MousePointer = vbHourglass
    objHttpProtocol.Send( objSmsMessage )
    MousePointer = vbDefault
    
    ' Display the result
    TextResult.Text = "ERROR #" & objHttpProtocol.LastError & " (" & objHttpProtocol.GetErrorDescription(objHttpProtocol.LastError) & ")"
    TextLastResponse.Text = objHttpProtocol.ProviderResponse
End Sub

Public Function FileExists(sFileName As String) As Boolean
  FileExists = CBool(Len(Dir$(sFileName))) And CBool(Len(sFileName))
End Function

Private Sub CommandView_Click()
If FileExists(TextLogFile.Text) = True Then
    Shell "notepad " + TextLogFile.Text, vbNormalFocus
    End If
End Sub

Private Sub Form_Load()
    Set objHttpProtocol = CreateObject("ActiveXperts.SmsProtocolHttp")
    Set objSmsConstants = CreateObject("ActiveXperts.SmsConstants")
    Set objSmsMessage   = CreateObject("ActiveXperts.SmsMessage")
    
    SetDefaultLogFile
End Sub

Private Function SetDefaultLogFile()
    Dim Buffer As String
    Buffer = Space(MAX_PATH)
    
    If GetTempPath(MAX_PATH, Buffer) <> 0 Then
        TextLogFile.Text = Left$(Buffer, InStr(Buffer, vbNullChar) - 1) & "SmsProtocolHttpLog.txt"
    Else
        TextLogFile.Text = "C:\SmsProtocolHttpLog.txt"
    End If
End Function

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.