You are here:
ActiveXperts.com > SMS and MMS Toolkit > How to Use SMS and MMS Toolkit > GSM/GPRS (MM1) > ASP.NET (Visual Basic)
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 ASP.NET projects.
You must install and configre Internet Information Services (IIS) before using the SMS and MMS Toolkit with ASP .NET If you don't have IIS installed, use the following steps:
From the Control Panel, click 'Add/Remove Programs'. Select the 'Add/Remove Windows Components' icon from the left pane, then select 'Application Server' and click on 'Details'. You can now select both 'ASP .NET' and 'Internet Information Services (IIS)'. Click 'OK' to continue installation;
(Click on the picture to enlarge)
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 'Web Site'. In the 'Web Site' dialog, select ASP .NET Web Site. 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 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 objects:
Dim objMmsProtocolMm1 As MmsProtocolMm1
Dim objMmsMessage As MmsMessage
Dim objMmsSlide As MmsSlide
Dim objMmsConstants As MmsConstants
objMmsProtocolMm1 = New MmsProtocolMm1 ()
objMmsConstants = new MmsConstants ()
There is no need to create the 'MmsSlide' and 'MmsMessage' objects, because they are returned by the 'MmsProtocolMm1' object while receiving messages.
You can now receive MMS messages.
The following code shows how to receive MMS messages:
Imports AXmsCtrl
Imports System.Collections.Generic
Partial Public Class SmsRecieve
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsPostBack = False Then
' Initialize instance of XMS Toolkit
Dim objGsmProtocol As SmsProtocolGsm
objGsmProtocol = New SmsProtocolGsm
' Clear the list
ddlDevices.Items.Clear()
ddlDevices.Items.Add(New ListItem("- - Select a device - -", ""))
' Display all devices connected to the computer
Dim intDeviceCount = objGsmProtocol.GetDeviceCount()
Dim i As Integer
For i = 0 To (intDeviceCount - 1)
Dim objDevice = objGsmProtocol.GetDevice(i)
ddlDevices.Items.Add(objDevice)
Next
' Set information
litVersion.Text = "Build: " & objGsmProtocol.Build & "; Module: " & objGsmProtocol.Module
End If
End Sub
Protected Sub btnGetMessages_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGetMessages.Click
If Page.IsValid Then
' Initialize instance of XMS Toolkit
Dim objGsmProtocol As SmsProtocolGsm
objGsmProtocol = New SmsProtocolGsm
' Set properties
If (String.IsNullOrEmpty(txtLogfile.Text) = False) Then
objGsmProtocol.LogFile = txtLogfile.Text
End If
objGsmProtocol.Device = ddlDevices.SelectedValue
objGsmProtocol.DeviceSpeed = Integer.Parse(ddlDeviceSpeed.SelectedValue)
If (String.IsNullOrEmpty(txtPin.Text) = False) Then
objGsmProtocol.EnterPin(txtPin.Text)
If (HandleError(objGsmProtocol) = False) Then
Return
End If
End If
' Recieve messages and display them
Dim intMessageCount As Integer
intMessageCount = objGsmProtocol.Receive()
If (HandleError(objGsmProtocol) = False) Then
Return
End If
Dim messages As IList(Of SmsMessage)
messages = New List(Of SmsMessage)
Dim i As Integer
For i = 0 To (intMessageCount - 1)
messages.Add(objGsmProtocol.GetMessage(i))
Next
gridMessages.DataSource = messages
gridMessages.DataBind()
litHR.Visible = True
End If
End Sub
Private Function HandleError(ByRef objComport As SmsProtocolGsm)
litResult.Text = objComport.LastError & " : " & objComport.GetErrorDescription(objComport.LastError)
Return (objComport.LastError = 0)
End Function
End Class
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 MMS Toolkit project ships with a set of Microsoft Visual Studio .NET samples, including samples for ASP.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.