ActiveXperts SMS Messaging Server Send, receive and automate SMS messages

Quicklinks


Send an SMS message using the SMS Messaging Server API - VBScript

SMS Messaging Server is an SMS messaging framework that enables companies to send, receive and process SMS- and e-mail messages. The framework is designed support virtually any scenario where low-and high volume SMS messaging is required. Use SMS Messaging Server in the following scenarios:

  • Mobile users query a database; results are sent back via SMS or e-mail;
  • Mobile users receive important information via SMS or e-mail while they are away from the office;
  • Stock prices are sent automatically via SMS and/or e-mail, daily;
  • Remote workers can update their worksheet from a remote location trough SMS;
  • ICT administrators restart/reboot servers and/or daemons from remote by SMS;
  • Setup an SMS voting system, supporting SMS and/or e-mail;
  • Etc.

SMS Messaging Server can be well integrated into VBScript environments. This document describes how the SMS Messaging Server can be integrated into VBScript projects.

Step 1: Download and install SMS Messaging Server

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

Step 2: Create a new script

Create a new script using your favorite editor. You can simply use notepad. However, a VBScript editor is recommended, so you can browse through objects, objects properties and object functions.

You're now able to write a more advanced VBScript program to create new messages.

Step 3: Create the SMS Messaging Server API objects

Create a new VBScript file called DEMO.VBS. It is recommended to insert the following line on top of your code:

Option Explicit

This statement requires that all variable names be defined (with the Dim statement), to avoid simple typos that can cause incredible headaches and long debugging sessions for something that should have never happened.

Now, declare the MessageDB and Constants objects:

Dim objMessageDB
Dim objMessage
Dim objConstants

Create the MessageDB and Constants objects:

Set objMessageDB = CreateObject( "Axsms-messaging-server.MessageDB" ) 
Set objConstants = CreateObject( "Axsms-messaging-server.Constants" ) 

You should not create an instance of a Message yourself; it is returned by functions like Create, FindFirstMessage, FindNextMessage and Load.

Step 4: Send an SMS (or e-mail) message

You can now send SMS and/or e-mail messages.

The following VBScript code shows how to send an SMS message:

Option Explicit

Dim objMessageDB, objMessage, objConstants
Dim numRecordID, strRecipient 

' Create objects
Set objMessageDB = CreateObject( "Axsms-messaging-server.MessageDB" ) 
Set objConstants = CreateObject( "Axsms-messaging-server.Constants" ) 

' Open the Database
objMessageDB.Open
WScript.Echo "Open, result: " & objMessageDB.LastError
If( objMessageDB.LastError <> 0 ) Then
   WScript.Quit
End If

' Create new Message in the Message Database
Set objMessage = objMessageDB.Create
WScript.Echo "Create, result: " & objMessageDB.LastError
If( objMessageDB.LastError = 0 ) Then
   WScript.Echo "ID of the new message: " & objMessage.ID

   ' Modify the Message
   objMessage.Direction     = objConstants.MESSAGEDIRECTION_OUT
   objMessage.Type          = objConstants.MESSAGETYPE_SMS
   objMessage.Status        = objConstants.MESSAGESTATUS_PENDING
   objMessage.ChannelID     = 0 ' Any available channel capable of handling this message
   objMessage.ScheduledTime = ""  'Immediate send
   objMessage.Recipient     = "+31625044454"
   objMessage.Body          = "SMS Messaging Server - VBScript Test SMS"

   ' Save the Message
   objMessageDB.Save objMessage
   WScript.Echo "Save, result: " & objMessageDB.LastError
End If


' Close the database
objMessageDB.Close
WScript.Echo "Message Dastabase closed."

WScript.Echo "Ready."