You are here:
ActiveXperts.com > SMS and MMS Toolkit > How to Use the SMS and MMS Toolkit > HTTP/SMS > Visual Basic 5.x/6.x
Quicklinks
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:
MMS features:
Pager features:
This document describes how the SMS and MMS Toolkit can be integrated into Visual Basic 5.x/6.x projects.
Download the SMS and MMS Toolkit from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.
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':
(Click on the picture to enlarge)
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:
(Click on the picture to enlarge)
Click 'OK' to close the 'References...' dialog.
Then, select the Project form and choose 'View Code' from the context menu:
(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")
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.