You are here:
ActiveXperts.com > SMS and MMS Toolkit > How to Use the SMS and MMS Toolkit > GSM phone or modem > Visual Basic .NET
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 .NET projects.
Download the 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 Studio (for instance 'Microsoft Visual Studio 2005') from the Start menu. Choose 'New' from the 'File' menu and click on 'Project'. In the 'New Project' dialog, select a Visual Studio template (for instance: 'Console Application'). Select a name for the application (for instance: 'DemoApp') and a name for the solution (for instance: 'DemoSolution'). Also, select the directory where you want to store the project (for instance: 'C:\MyProjects):
(Click on the picture to enlarge)
Now that a new project has been created, you must add a reference to the SMS and MMS Toolkit in the project to be able to use the the SMS and MMS Toolkit objects. To do so, choose 'Add Reference...' from the 'Project' menu. In the 'Add Reference' dialog that pops up, select the 'COM' tab and select the ActiveXperts SMS and MMS Toolkit Type Library' as shown in the following picture:
(Click on the picture to enlarge)
Click 'OK' to close the 'Add Reference' dialog.
On top of your code, type the following line to use the SMS and MMS Toolkit namespace:
Imports AXmsCtrl
In your Main function, declare and create the following object for GSM:
Dim objGsmProtocol As SmsProtocolGsm = New SmsProtocolGsm()
Insert the following line to declare and create the SmsMessage object:
Dim objSmsMessage As SmsMessage = New SmsMessage()
Insert the following line to declare and create the SmsConstants object:
Dim objSmsConstants As SmsConstants = New SmsConstants()
You can now send and receive SMS messages.
The following code shows how to send an SMS message using a connected GSM phone or modem:
Imports AXmsCtrl
Module Module1
Sub Main()
' Create instance of COM Object
Dim objGsmProtocol As SmsProtocolGsm = New SmsProtocolGsm()
Dim objSmsMessage As SmsMessage = New SmsMessage()
Dim objSmsConstants As SmsConstants = New SmsConstants()
' Device Settings
objGsmProtocol.Device = "COM1"
' Message Settings
objSmsMessage.Recipient = "+31647134225"
objSmsMessage.Data = "Hello World !"
objSmsMessage.Format = objSmsConstants.asMESSAGEFORMAT_TEXT
' Set Logfile
objGsmProtocol.LogFile = "C:\SMSLog.txt"
' Send the message !
Console.WriteLine ("")
objGsmProtocol.Send( objSmsMessage )
If objGsmProtocol.LastError = 0 Then
Console.WriteLine ("")
Console.WriteLine ("Your message was delivered successfully")
Console.WriteLine ("")
Else
Console.WriteLine ("")
Console.WriteLine ("Sending message failed, Error code = {0} ( {1} )",
objGsmProtocol.LastError.ToString,
objGsmProtocol.GetErrorDescription(objGsmProtocol.LastError))
Console.WriteLine ("")
End If
End Sub
End Module
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.
The the SMS and MMS Toolkit project ships with a set of Microsoft Visual Studio .NET samples, including samples for Microsoft Visual Basic .NET. The projects are created with Microsoft Visual Studio 2005.
Users with a later version of Microsoft Visual Studio can open such a project. The Visual Studio Conversion Wizard will guide you through the process of converting the project to the version used.