You are here:
ActiveXperts.com > SMS and MMS Toolkit > How to Use MMS Toolkit > SMTP (MM4) > 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;
Make sure that ASP .NET is allowed on the web server:
(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 objMmsProtocolMm4 As MmsProtocolMm4
Dim objMmsMessage As MmsMessage
Dim objMmsSlide As MmsSlide
Dim objMmsConstants As MmsConstants
objMmsProtocolMm4 = New MmsProtocolMm4 ()
objMmsMessage = new MmsMessage ()
objMmsSlide = new MmsSlide ()
objMmsConstants = new MmsConstants ()
You can now send MMS messages.
The following code shows how to send a MMS message:
Imports AXmsCtrl
Public Class MmsMm4Form
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Label4 As System.Web.UI.WebControls.Label
Protected WithEvents Label5 As System.Web.UI.WebControls.Label
Protected WithEvents ctlResult As System.Web.UI.WebControls.TextBox
Protected WithEvents Label7 As System.Web.UI.WebControls.Label
Protected WithEvents ctlSendMessage As System.Web.UI.WebControls.Button
Protected WithEvents ctlAttachment As System.Web.UI.WebControls.TextBox
Protected WithEvents Label14 As System.Web.UI.WebControls.Label
Protected WithEvents ctlMSG As System.Web.UI.WebControls.TextBox
Protected WithEvents Label6 As System.Web.UI.WebControls.Label
Protected WithEvents ctlSubject As System.Web.UI.WebControls.TextBox
Protected WithEvents Label13 As System.Web.UI.WebControls.Label
Protected WithEvents ctlSender As System.Web.UI.WebControls.TextBox
Protected WithEvents Label12 As System.Web.UI.WebControls.Label
Protected WithEvents ctlRecipient As System.Web.UI.WebControls.TextBox
Protected WithEvents Label9 As System.Web.UI.WebControls.Label
Protected WithEvents Label3 As System.Web.UI.WebControls.Label
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents ctlAccount As System.Web.UI.WebControls.TextBox
Protected WithEvents ctlPort As System.Web.UI.WebControls.TextBox
Protected WithEvents ctlDomain As System.Web.UI.WebControls.TextBox
Protected WithEvents ctlPassword As System.Web.UI.WebControls.TextBox
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents ctlHost As System.Web.UI.WebControls.TextBox
Private objMm4Protocol As MmsProtocolMm4
Private objMmsMessage As MmsMessage
Private objConstants As MmsConstants
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
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
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
objMm4Protocol = New MmsProtocolMm4
objMmsMessage = New MmsMessage
objConstants = New MmsConstants
If (Not IsPostBack) Then
ctlPort.Text = "25"
ctlAttachment.Text = "C:\Windows\system32\clock.avi"
End If
End Sub
Private Sub UpdateResult(ByVal numResult As System.Int32)
ctlResult.Text = numResult.ToString() & ": " & objMm4Protocol.GetErrorDescription(numResult)
End Sub
Private Sub ctlSendMessage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctlSendMessage.Click
Dim objSlide As MmsSlide = New MmsSlide
Dim objMessage As MmsMessage = New MmsMessage
objSlide.Clear()
objSlide.AddText(ctlMSG.Text)
objSlide.AddAttachment(ctlAttachment.Text, 0)
' Create MMS Message and add slide including text and image
objMessage.Clear()
objMessage.AddRecipient(ctlRecipient.Text, objConstants.asMMS_RECIPIENT_TO)
objMessage.From = ctlSender.Text
objMessage.Subject = ctlSubject.Text
objMessage.AddSlide(objSlide)
objMm4Protocol.Clear()
objMm4Protocol.ProviderHost = ctlHost.Text
objMm4Protocol.ProviderDomain = ctlDomain.Text
objMm4Protocol.ProviderAccount = ctlAccount.Text
objMm4Protocol.ProviderPassword = ctlPassword.Text
objMm4Protocol.ProviderPort = System.Int32.Parse(ctlPort.Text)
' objMm4Protocol.LogFile = "c:\mmsmm4.log"
' Send
objMm4Protocol.Send(objMessage)
UpdateResult(objMm4Protocol.LastError)
End Sub
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.