You are here:
ActiveXperts.com > SMS and MMS Toolkit > How to Use MMS Toolkit > SOAP (MM7) > Visual C# .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:
using AXmsCtrlIn your Main function, declare and create the following objects:
public MmsProtocolMm7 objMMSConnection; public MmsMessage objMmsMessage; public MmsSlide objMmsSlide; public MmsConstants objMmsConstants; objMMSConnection = new MmsProtocolMm7 (); 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:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using AXmsCtrl;
namespace Demo
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
internal System.Windows.Forms.GroupBox GroupBox4;
internal System.Windows.Forms.Button ButtonView;
internal System.Windows.Forms.TextBox TextLogfile;
internal System.Windows.Forms.TextBox TextResponse;
internal System.Windows.Forms.TextBox TextResult;
internal System.Windows.Forms.Label Label16;
internal System.Windows.Forms.Label Label15;
internal System.Windows.Forms.Label Label14;
internal System.Windows.Forms.GroupBox GroupBox3;
internal System.Windows.Forms.Button ButtonSend;
internal System.Windows.Forms.Button ButtonBrowse;
internal System.Windows.Forms.TextBox TextAttachment;
internal System.Windows.Forms.TextBox TextBody;
internal System.Windows.Forms.TextBox TextSubject;
internal System.Windows.Forms.TextBox TextSender;
internal System.Windows.Forms.TextBox TextRecipient;
internal System.Windows.Forms.Label Label13;
internal System.Windows.Forms.Label Label12;
internal System.Windows.Forms.Label Label11;
internal System.Windows.Forms.Label Label10;
internal System.Windows.Forms.Label Label9;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
internal System.Windows.Forms.GroupBox GroupBox2;
internal System.Windows.Forms.ComboBox ComboVersion;
internal System.Windows.Forms.ComboBox ComboScheme;
internal System.Windows.Forms.Label Label6;
internal System.Windows.Forms.Label Label5;
internal System.Windows.Forms.ComboBox ComboVariation;
internal System.Windows.Forms.Label Label4;
internal System.Windows.Forms.GroupBox GroupBox5;
internal System.Windows.Forms.GroupBox GroupBox1;
internal System.Windows.Forms.TextBox TextPassword;
internal System.Windows.Forms.TextBox TextAccount;
internal System.Windows.Forms.Label Label3;
internal System.Windows.Forms.Label Label2;
internal System.Windows.Forms.CheckBox CheckAuthentication;
internal System.Windows.Forms.CheckBox CheckSSL;
internal System.Windows.Forms.TextBox TextURL;
internal System.Windows.Forms.Label Label1;
internal System.Windows.Forms.Button ButtonSaveCfg;
internal System.Windows.Forms.Button ButtonLoadCfg;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
public MmsProtocolMm7 objMMSConnection;
public MmsMessage objMmsMessage;
/*****************************************************************************************************/
private void Form1_Load(object sender, System.EventArgs e)
{
objMMSConnection = new MmsProtocolMm7 ();
objMmsMessage = new MmsMessageClass ();
ComboVariation.Items.Add("3GPP");
ComboVariation.Items.Add("Ericsson");
ComboVariation.Items.Add("PAP");
ComboVariation.SelectedIndex = 0;
ComboScheme.Items.Add("REL-5-MM7-1-0");
ComboScheme.Items.Add("REL-5-MM7-1-1");
ComboScheme.Items.Add("REL-5-MM7-1-2");
ComboScheme.Items.Add("REL-5-MM7-1-3");
ComboScheme.Items.Add("REL-5-MM7-1-4");
ComboScheme.Items.Add("REL-5-MM7-1-5");
ComboScheme.Items.Add("REL-6-MM7-1-0");
ComboScheme.Items.Add("REL-6-MM7-1-1");
ComboScheme.Items.Add("REL-6-MM7-1-2");
ComboScheme.Items.Add("REL-6-MM7-1-3");
ComboScheme.SelectedIndex = 0;
ComboVersion.Items.Add("5.2.0");
ComboVersion.Items.Add("5.3.0");
ComboVersion.Items.Add("5.4.0");
ComboVersion.Items.Add("5.5.0");
ComboVersion.Items.Add("5.6.0");
ComboVersion.Items.Add("5.7.0");
ComboVersion.Items.Add("5.8.0");
ComboVersion.Items.Add("5.9.0");
ComboVersion.Items.Add("5.10.0");
ComboVersion.Items.Add("5.11.0");
ComboVersion.Items.Add("6.0.0");
ComboVersion.Items.Add("6.1.0");
ComboVersion.Items.Add("6.2.0");
ComboVersion.Items.Add("6.3.0");
ComboVersion.Items.Add("6.4.0");
ComboVersion.Items.Add("6.5.0");
ComboVersion.Items.Add("6.6.0");
ComboVersion.Items.Add("6.7.0");
ComboVersion.SelectedIndex = 0;
if (TextAccount.TextLength > 0)
{
CheckAuthentication.Checked = true;
}
EnableControls();
TextLogfile.Text = System.IO.Path.GetTempPath() + "MMSLog.txt";
}
/*****************************************************************************************************/
private void ButtonLoadCfg_Click(object sender, System.EventArgs e)
{
openFileDialog1.DefaultExt = ".mm7";
openFileDialog1.Filter = "MMS Connection Files (*.mm7)|*.mm7";
if ( openFileDialog1.ShowDialog() == DialogResult.OK )
{
objMMSConnection.ProviderProviderLoadConfig(openFileDialog1.FileName);
if ( GetResult() == 0)
{
TextURL.Text = objMMSConnection.ProviderURL;
TextAccount.Text = objMMSConnection.ProviderAccount;
TextPassword.Text = objMMSConnection.ProviderPassword;
CheckSSL.Checked = objMMSConnection.ProviderUseSSL != 0 ? true : false;
ComboScheme.SelectedIndex = objMMSConnection.ProviderMM7Schema;
ComboVariation.SelectedIndex = objMMSConnection.ProviderMM7Variation;
ComboVersion.SelectedIndex = objMMSConnection.ProviderMM7Version;
if (TextAccount.TextLength > 0)
{
CheckAuthentication.Checked = true;
}
EnableControls();
}
}
}
/*****************************************************************************************************/
private void ButtonSaveCfg_Click(object sender, System.EventArgs e)
{
saveFileDialog1.DefaultExt = ".mm7";
saveFileDialog1.Filter = "MMS Connection Files|mm7";
if ( saveFileDialog1.ShowDialog() == DialogResult.OK )
{
objMMSConnection.LogFile = TextLogfile.Text;
objMMSConnection.ProviderURL = TextURL.Text;
objMMSConnection.ProviderAccount = TextAccount.Text;
objMMSConnection.ProviderPassword = TextPassword.Text;
objMMSConnection.ProviderUseSSL = CheckSSL.Checked ? -1 : 0;
objMMSConnection.ProviderMM7Schema = ComboScheme.SelectedIndex;
objMMSConnection.ProviderMM7Variation = ComboVariation.SelectedIndex;
objMMSConnection.ProviderMM7Version = ComboVariation.SelectedIndex;
objMMSConnection.ProviderSaveConfig(saveFileDialog1.FileName);
GetResult ();
}
}
/*****************************************************************************************************/
private long GetResult ()
{
if (objMMSConnection.LastError == 0)
{
TextResult.Text = "SUCCESS";
}
else
{
TextResult.Text = "ERROR #" + objMMSConnection.LastError + " (" + objMMSConnection.GetErrorDescription(objMMSConnection.LastError) + ")";
}
TextResponse.Text = objMMSConnection.ProviderResponse;
return objMMSConnection.LastError;
}
/*****************************************************************************************************/
private void ButtonSend_Click(object sender, System.EventArgs e)
{
MmsSlide objMmsSlide;
//Set connection parameters
objMMSConnection.ProviderURL = TextURL.Text;
objMMSConnection.ProviderAccount = TextAccount.Text;
objMMSConnection.ProviderPassword = TextPassword.Text;
objMMSConnection.ProviderUseSSL = CheckSSL.Checked ? -1 : 0;
objMMSConnection.ProviderMM7Schema = ComboScheme.SelectedIndex;
objMMSConnection.ProviderMM7Variation = ComboVariation.SelectedIndex;
objMMSConnection.ProviderMM7Version = ComboVariation.SelectedIndex;
objMMSConnection.LogFile = TextLogfile.Text;
//Create MMS Message and add slide including text and image
objMmsMessage.Clear();
objMmsMessage.AddRecipient(TextRecipient.Text);
objMmsMessage.From = TextSender.Text;
objMmsMessage.Subject = TextSubject.Text;
objMmsSlide = new MmsSlide ();
object obj1 = null;
objMmsSlide.AddText(TextBody.Text);
objMmsSlide.AddAttachment(TextAttachment.Text, ref obj1);
obj1 = objMmsSlide;
objMmsMessage.AddSlide ( ref obj1 );
Cursor.Current = Cursors.WaitCursor;
//Connect to MMSC
object obj = objMmsMessage;
objMMSConnection.Send (ref obj );
GetResult();
Cursor.Current = Cursors.Default;
}
/*****************************************************************************************************/
private void ButtonView_Click(object sender, System.EventArgs e)
{
if (System.IO.File.Exists(TextLogfile.Text.ToString()))
{
System.Diagnostics.Process.Start(TextLogfile.Text);
}
}
/*****************************************************************************************************/
private void EnableControls ()
{
TextAccount.Enabled = CheckAuthentication.Checked;
TextPassword.Enabled = CheckAuthentication.Checked;
}
/*****************************************************************************************************/
private void ButtonBrowse_Click(object sender, System.EventArgs e)
{
openFileDialog1.Filter = "All Multimedia Files|*";
if ( openFileDialog1.ShowDialog() == DialogResult.OK )
{
TextAttachment.Text = openFileDialog1.FileName;
}
}
/*****************************************************************************************************/
}
}
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 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.