Shortcut Menu

Skip

Main Navigation

Choose your language


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 for Applications

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 VBA 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 Excel document

Create the form displayed in the image below. To create the buttons, textarea's and drop down menu's, click "View", "Toolbars", "Control toolbox".

(Click on the picture to enlarge)

Step 3: Fill in the dropdown-menu's

In this sample, we're creating a form that is able to send an SMS in Microsoft Excel. Sending an SMS with our SMS and MMS Toolkit can be done in just a few lines of code. The core of this little system is the SmsProtocolSmpp object witch is the first line of code that must be typed down in your code. After that, just add the phone-number, the message, tell the system what port the device is connected to and eventually send the message.

You can configure a lot of extra options. Few of them are used in this sample. More information about those options are to be found in the products manual whitch is shipped with our product. In this sample we are configuring a logfile, the message type, we are checking the status of the SMS (Whether it has been sent or not) and we're displaying the modems connected to the computer.

In this sample we work with forms. It is possible to work with just the fields too. To create an excel file whitch is able to send an SMS, first of all, create a new excel file with the form that is displayed below in it.


Visual Basic for Appplications

(Click on the picture to enlarge)

A lot of things in this form are optional. Basically you only need the fields mentioned below:

  • The device field
  • The pincode field
  • The recipient field
  • The message

Make sure you don't forget to create a submit button.

The first and most important thing is to create the ActiveXperts objects. To do that means we need to type some code. You can add code to an excel sheet. Click "View", "Toolbars" and then "Control Toolbox". You will see a "Design Mode"-icon (VBA), click it. Double click the submit button you created in your form. The MicroSoft Visual Basic Editor will now be opened. You can type all code here.

The ActiveXperts objects have to be public variables because they are used in different subs. Use the following code for that.

'Declare the object variables
 Public objSmppProtocol As Object
 Public objSmsMessage As Object 
 Public objSmsConstants As Object 

To fill these variables with the ActiveXperts Software, we're creating a function so in any situation we're sure the object is loaded properly. Use the following code:

Sub createobjects()

  '###########################  set the objects  ###########################
  
  If objSmppProtocol Is Nothing Then
     Set objSmppProtocol = CreateObject("ActiveXperts.SmsProtocolSmpp")
     Set objSmsMessage   = CreateObject("ActiveXperts.SmsMessage")
     Set objSmsConstants = CreateObject("ActiveXperts.SmsConstants")
  Else
  End If

  
End Sub

In the sample we created a seperate sub for sending the SMS. If the submit button is clicked fist a check is preformed. If the phone number is correct the SMS will be sent. The objects we've created work with the SMS and MMS Toolkit. Every property of the toolkit can used with a dot. Every object has its own properties whitch can be found in the products manual that is shipped with the product. Here is an example of how to call to a property. This script wil print the version of the SMS and MMS Toolkit's version in a messagebox.

Sub createobjects()

   Dim objSmppProtocol as Object
   Dim objSmsMessage as Object
   Dim objSmsConstants as Object

   Set objSmppProtocol = CreateObject("ActiveXperts.SmsProtocolSmpp")
   Set objSmsMessage   = CreateObject("ActiveXperts.SmsMessage")
   Set objSmsConstants = CreateObject("ActiveXperts.SmsConstants")

   msgbox(objSmppProtocol.Version)
  
End Sub

To send the SMS we need to collect the information entered the user and use it to send the SMS. When you're writing your script make sure the script stops if any command has not executed properly. You are able to check this using the "LastError" property in our toolkit. Here is an example what you could make your script look like.

Sub sendSMS()

  'empty some fields in the form
  txtStatus.Value = ""
  txtStatusRecipient.Value = ""
  txtTime.Value = ""

  'create the objects
  createobjects
  
  objSmppProtocol.Clear
  objSmsMessage.Clear
  
  '################# configure the logfile and the device ##################
    
  'set the logfile
  objSmppProtocol.Logfile = txtLogfile.Value
  
  ' set the SMPP server properties
  objSmppProtocol.Server = strServer
  objSmppProtocol.ServerPort = CInt(strPort)
  objSmppProtocol.SystemID = strSystemID
  objSmppProtocol.SystemPassword = strPassword
  objSmppProtocol.SystemType = strSystemType
  objSmppProtocol.SystemSourceAddress = strSourceAddress
  objSmppProtocol.SystemMode = objConstants.asSMPPMODE_TRANSMITTER
   
    
  '######################## Fill in the message type #######################

  
  If objSmppProtocol.LastError = 0 Then
     
      'set default
      objSmsMessage.Format = objSmsConstants.asMESSAGEFORMAT_TEXT
     
      'unicode multipart messages
      If cbAllowMultipartMessages = True Then
          objSmsMessage.Format = objSmsConstants.asMESSAGEFORMAT_TEXT_MULTIPART
      Else
      End If
  
      'unicode imidiate display
      If cbImidiateDisplay = True Then
          objSmsMessage.Format = objSmsConstants.asMESSAGEFORMAT_TEXT_FLASH
      Else
      End If
  
      'unicode messages
      If cbUnicode = True Then
          
          objSmsMessage.Format = objSmsConstants.asMESSAGEFORMAT_UNICODE
    
          'unicode multipart messages
          If cbAllowMultipartMessages = True Then
              objSmsMessage.Format = objSmsConstants.asMESSAGEFORMAT_UNICODE_MULTIPART
          Else
          End If
  
          'unicode imidiate display
          If cbImidiateDisplay = True Then
              objSmsMessage.Format = objSmsConstants.asMESSAGEFORMAT_UNICODE_FLASH
          Else
          End If
  
      Else
      End If
  
  Else
  End If
  
  
  
  '###################### Request message report ###########################
  If objSmppProtocol.LastError = 0 Then
    If cbRequestDeliveryReport = True Then
       objSmsMessage.RequestDeliveryStatus = True
    Else
    End If
  Else
  End If
  
  
  
  '#################### Create and send the message ########################
  
  
  If objSmppProtocol.LastError = 0 Then
    'create the SMS
    objSmsMessage.Format = txtRecipient.Value
    objSmsMessage.Data = txtMessage.Value
  Else
  End If
  
  If objSmppProtocol.LastError = 0 Then
    'send the SMS
    objSmppProtocol.Send( objSmsMessage )
  Else
  End If

  
  
  '########################### Get the results ##############################
  
  'get the result
  txtResult.Value = objSmppProtocol.LastError & " : " & objSmppProtocol.GetErrorDescription(objSmppProtocol.LastError)
  
End Sub

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.