You are here:
ActiveXperts.com > SMS and MMS Toolkit > How to Use the SMS and MMS Toolkit > SMPP Provider > 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 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:
(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 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:
Private objSmppProtocol As SmsProtocolSmpp Private objSmsMessage As SmsMessage Private objSmsConstants As SmsConstants objSmppProtocol = New SmsProtocolSmpp() objSmsMessage = New SmsMessage() objSmsConstants = New SmsConstants()
You can now send and/or receive SMS messages.
The following code shows how to send a SMS message:
webform.aspx.vb
Imports AXmsCtrl
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents Text1 As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents TextMessage As System.Web.UI.HtmlControls.HtmlTextArea
Protected WithEvents CheckboxUnicode As System.Web.UI.HtmlControls.HtmlInputCheckBox
Protected WithEvents Submit As System.Web.UI.HtmlControls.HtmlInputButton
Protected WithEvents TextRecipient As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents TextResult As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents Form As System.Web.UI.HtmlControls.HtmlForm
Protected WithEvents TextReference As System.Web.UI.HtmlControls.HtmlInputText
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
'///////////////////////////////////////////////////////////////////////////////////////////////////////
Public objSmppProtocol As SmsProtocolSmpp
Public objSmsMessage As SmsMessage
Public objSmsConstants As SmsConstants
'///////////////////////////////////////////////////////////////////////////////////////////////////////
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
objSmppProtocol = New SmsProtocolSmpp()
objSmsMessage = New SmsMessage()
objSmsConstants = New SmsConstants()
End Sub
'///////////////////////////////////////////////////////////////////////////////////////////////////////
Private Sub Submit_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Submit.ServerClick
Dim strReference as String
objSmppProtocol.Server = "smpp.activexperts-labs.com"
objSmppProtocol.ServerPort = 2775
objSmppProtocol.SystemID = "AX008"
objSmppProtocol.SystemPassword = "812056"
objSmppProtocol.SystemType = "SMPP"
objSmppProtocol.ServerTimeout = 10000
objSmppProtocol.SystemMode = objSmsConstants.asSMPPMODE_TRANSMITTER
objSmppProtocol.LogFile = "C:\\SmsLogAsp.txt"
objSmsMessage.Recipient = TextRecipient.Value
objSmsMessage.Data = TextMessage.Value
If (CheckboxUnicode.Checked = True) Then
objSmsMessage.Format = objSmsConstants.asMESSAGEFORMAT_UNICODE
Else
objSmsMessage.Format = objSmsConstants.asMESSAGEFORMAT_TEXT
End If
Submit.Disabled = True
objSmppProtocol.Connect()
Submit.Disabled = False
If (objSmppProtocol.LastError <>0) Then
TextResult.Value = "ERROR #" & objSmppProtocol.LastError & " (" & objSmppProtocol.GetErrorDescription(objSmppProtocol.LastError) & ")"
Exit Sub
End If
Submit.Disabled = True
strReference = objSmppProtocol.Send( objSmsMessage )
Submit.Disabled = False
If (objSmppProtocol.LastError <> 0) Then
TextResult.Value = "ERROR #" & objSmppProtocol.LastError & " (" & objSmppProtocol.GetErrorDescription(objSmppProtocol.LastError) & ")"
TextReference.Value = ""
Else
TextResult.Value = "SUCCESS"
TextReference.Value = strReference
End If
objSmppProtocol.Disconnect()
End Sub
'///////////////////////////////////////////////////////////////////////////////////////////////////////
End Class
webform.aspx
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="SendSms.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>ActiveXperts SMS and MMS Toolkit ASP.NET Sample (VB)</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body>
<font face="sans-serif" size="2">
<hr size="1" color="#707070">
<h2>ActiveXperts SMS and MMS Toolkit ASP.NET Sample (VB)</h2>
<h3>Send an SMS message to a recipient through an SMPP provider.</h3>
IMPORTANT: For more details about using SMS and MMS Toolkit with ASP.NET: <a href="http://www.activexperts.com/support/xmstoolkit/#aspnet" target="_blank">
SMS and MMS Toolkit ASP.NET FAQ</a>.
<hr size="1" color="#707070">
<br>
<form id="Form" method="post" runat="server">
<table border="0" bgcolor="#f0f0f0">
<tr>
<td valign="top">Recipient:</td>
<td><input size="50" type="text" value="<enter recipient number>" id="TextRecipient" runat="server"></td>
</tr>
<tr>
<td valign="top">Message:<br>(max. 160 chars)</td>
<td><textarea rows="3" cols="65" id="TextMessage" runat="server">Hello, world</textarea></td>
</tr>
<tr>
<td valign="top"> </td>
<td><input type="checkbox" id="CheckboxUnicode" runat="server">Send message as Unicode</td>
</tr>
<tr>
<td valign="top">Result: </td>
<td><input size="50" type="text" id="TextResult" runat="server"></td>
</tr>
<tr>
<td valign="top">Message Reference: </td>
<td><input size="50" type="text" id="TextReference" runat="server"></td>
</tr>
</table>
<br>
<hr size="1" color="#707070">
<br>
<input type="submit" value="Send Message" id="Submit" runat="server">
<br>
<br>
<hr size="1" color="#707070">
</form>
</font>
</body>
</html>
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 SMS and MMS Toolkit project ships with a set of Microsoft Visual Studio .NET samples, including samples for Microsoft ASP .NET (Visual Basic). 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.