You are here:
ActiveXperts.com > SMS and MMS Toolkit > How to Use MMS Toolkit > GSM/GPRS (MM1) > 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 objects:
Dim objMmsProtocolMm1 As MmsProtocolMm1
Dim objMmsMessage As MmsMessage
Dim objMmsSlide As MmsSlide
Dim objMmsConstants As MmsConstants
objMmsProtocolMm1 = New MmsProtocolMm1 ()
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:
Public objMMSConnection As MmsProtocolMm1 Public objMmsMessage As MmsMessage '////////////////////////////////////////////////////////////////////////////////////////////////////// Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim n, nNumDevices objMMSConnection = New MmsProtocolMm1() objMmsMessage = New MmsMessage() nNumDevices = objMMSConnection.GetDeviceCount() For n = 0 To nNumDevices - 1 ComboDevice.Items.Add(objMMSConnection.GetDevice(n)) ComboDevice.SelectedIndex = 0 Next TextLogfile.Text = System.IO.Path.GetTempPath() & "MMSLog.txt" End Sub '////////////////////////////////////////////////////////////////////////////////////////////////////// Private Sub ButtonSaveCfg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSaveCfg.Click With SaveFileDialog1 .DefaultExt = "mm1" .Filter = "MMS Connection Files|mm1" End With If SaveFileDialog1.ShowDialog() = DialogResult.OK Then With objMMSConnection .ProviderMMSC = TextServerAddress.Text .ProviderAPN = TextServerAPN.Text .ProviderWAPGateway = TextServerGateway.Text .ProviderAPNAccount = TextServerLogin.Text .ProviderAPNPassword = TextServerPassword.Text .ProviderSaveConfig(SaveFileDialog1.FileName) End With End If End Sub '////////////////////////////////////////////////////////////////////////////////////////////////////// Private Sub ButtonLoadCfg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonLoadCfg.Click With OpenFileDialog1 .DefaultExt = ".mm1" .Filter = "MMS Connection Files|*.mm1" End With If OpenFileDialog1.ShowDialog() = DialogResult.OK Then objMMSConnection.ProviderProviderLoadConfig(OpenFileDialog1.FileName) If (GetResult() = 0) Then TextServerAddress.Text = objMMSConnection.ProviderMMSC TextServerAPN.Text = objMMSConnection.ProviderAPN TextServerGateway.Text = objMMSConnection.ProviderWAPGateway TextServerLogin.Text = objMMSConnection.ProviderAPNAccount TextServerPassword.Text = objMMSConnection.ProviderAPNPassword End If End If End Sub '////////////////////////////////////////////////////////////////////////////////////////////////////// Private Function GetResult() If (objMMSConnection.LastError = 0) Then TextResult.Text = "SUCCESS" Else TextResult.Text = "ERROR #" & objMMSConnection.LastError _& & " (" & objMMSConnection.GetErrorDescription(objMMSConnection.LastError) & ")" End If TextResponse.Text = objMMSConnection.ServerResponse GetResult = objMMSConnection.LastError End Function '////////////////////////////////////////////////////////////////////////////////////////////////////// Private Sub ButtonSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSend.Click Dim objMmsSlide As MmsSlide 'Set connection parameters With objMMSConnection .Device = ComboDevice.Text .ProviderMMSC = TextServerAddress.Text .ProviderAPN = TextServerAPN.Text .ProviderWAPGateway = TextServerGateway.Text .ProviderAPNAccount = TextServerLogin.Text .ProviderAPNPassword = TextServerPassword.Text .LogFile = TextLogfile.Text End With 'Create MMS Message and add slide including text and image With objMmsMessage .Clear() .AddRecipient(TextRecipient.Text) .From = TextSender.Text .Subject = TextSubject.Text End With objMmsSlide = new MmsSlide () objMmsSlide.AddText(TextBody.Text) objMmsSlide.AddAttachment(TextAttachment.Text) objMmsMessage.AddSlide ( objMmsSlide ) Cursor.Current = Cursors.WaitCursor 'Connect to MMSC objMMSConnection.Connect() If (GetResult() = 0) Then objMMSConnection.Send(objMmsMessage) GetResult() objMMSConnection.Disconnect() End If Cursor.Current = Cursors.Default End Sub '////////////////////////////////////////////////////////////////////////////////////////////////////// Private Sub ButtonView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonView.Click If (System.IO.File.Exists(TextLogfile.Text.ToString())) Then System.Diagnostics.Process.Start(TextLogfile.Text) End If End Sub '////////////////////////////////////////////////////////////////////////////////////////////////////// Private Sub ButtonBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonBrowse.Click With OpenFileDialog1 .Filter = "All Multimedia Files|*" End With If OpenFileDialog1.ShowDialog() = DialogResult.OK Then TextAttachment.Text = OpenFileDialog1.FileName End If 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/XmsToolkit.
The 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.