You are here:
ActiveXperts.com > SMS and MMS Toolkit > How to Use the SMS and MMS Toolkit > GSM phone or modem > 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 the SMS and MMS Toolkit 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:
Dim objGsmProtocol As AXmsCtrl.SmsProtocolGsm 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 GSM objects in the following way:
Set objGsmProtocol = CreateObject("ActiveXperts.SmsProtocolGsm")
Set objSmsMessage = CreateObject("ActiveXperts.SmsMessage")
Set objSmsConstants = CreateObject("ActiveXperts.SmsConstants")
The following code snippet shows how to send an SMS message using a connected GSM phone or modem:
Private Sub buttonSend_Click()
Dim Format As Long
buttonSend.Enabled = False
textResult.Caption = "Sending message, Please wait..."
textResult.Refresh
' Set Device
objGsmProtocol.Device = comboDevice.Text
' Set LogFile
objGsmProtocol.LogFile = textLogfile.Text
' Set Speed
If comboSpeed.ListIndex = 0 Then
objGsmProtocol.DeviceSpeed = 0 ' use default speed
Else
objGsmProtocol.DeviceSpeed = comboSpeed.List(comboSpeed.ListIndex)
End If
' Set Format
objSmsMessage.Format = objConstants.asMESSAGEFORMAT_TEXT
If SendConfig.checkMultipart.Value = 1 Then
objSmsMessage.Format = objConstants.asMESSAGEFORMAT_TEXT_MULTIPART
End If
If SendConfig.checkFlash.Value = 1 Then
objSmsMessage.Format = objConstants.asMESSAGEFORMAT_TEXT_FLASH
End If
' Set Delivery Report
objSmsMessage.RequestDeliveryStatus = SendConfig.checkReport.Value
' Set recipient
objSmsMessage.Recipient = textRecipient.Text
' Set Message parameters
objSmsMessage.Data = textMessage.Text
' Send the message
objGsmProtocol.Send( objSmsMessage )
' Display result
ShowReference = True
GetResult (True)
ShowReference = False
buttonSend.Enabled = True
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.