Download ActiveXperts SMS and MMS Toolkit 5.1  (6826 KB - .exe file)
Download Manual  (623 KB - .htm file)
Using SMS and MMS Toolkit with ASP.NET C# (MM1 Connection)
The SMS and MMS Toolkit is a software development kit (SDK) to enhance an application or script with SMS, MMS and Pager functionality.
An 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.
An MMS messages can be sent via a GSM/GPRS modem (MM1), an SMTP server (MM4) or an XML/SOAP compliant provider (MM7).
SMS features:
- Send and receive numeric- and alphanumeric text SMS messages
- Verify delivery of outgoing SMS messages
- Support for multimedia SMS messages, including ringtones, pictures and logo's
- Support for WAP Push, WAP Bookmarks, vCards, voicemail/e-mail/fax/MMS indications
- Support for Unicode, to support foreign languages like Chinese, Turkisch, etc.
- Support for multi-part messages, to allow messages longer than 160 characters
- Support for GSM modems, GSM phones, SMS/HTTP providers, SMPP (Short Message Peer to Peer) providers, TAP/XIO and UCP dial-in SMSC providers
- Support Multi-threading environments. The component is thread-safe, which means it can be used in a multi-threaded environment
- Samples included for various development platforms: MS Visual Basic, MS Visual Basic .NET, MS Visual C++, MS Visual Studio C# .NET, ASP, ASP .NET, Borland Delphi, Borland C++ Builder, ColdFusion and more
MMS features:
- Support for many multimedia formats incl.: JPG, GIF, PNG, BMP, WBMP, TIF, WAV, MP3, MIDI, AC3, GP3, AVI, MPG, MP4, VCARD, VCALENDAR, JAR and more
- Support for MM1 (MMS over WAP), MM4 (MMS over SMTP) and MM7 (MMS over HTML/SOAP)
Pager features:
- Send alpha-numeric Pager messages through SNPP
This document describes how the SMS and MMS Toolkit can be integrated into ASP.NET projects.
Prerequisites
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)
Step 1: Download and install the SMS and MMS Toolkit
Download the the SMS and MMS Toolkit from the ActiveXperts Download Site and start the installation.
The installation guides you through the installation process.
Step 2: Create a new ASP .NET C# Project
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)
Step 3: Refer to the SMS and MMS Toolkit Library
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:
using AXmsCtrl;
Step 4: Declare and create the MMS objects
In your Main function, declare and create the following objects:
public MmsProtocolMm1 objMmsProtocolMm1;
public MmsMessage objMmsMessage;
public MmsSlide objMmsSlide;
public MmsConstants objMmsConstants;
objMmsProtocolMm1 = new MmsProtocolMm1 ();
objMmsMessage = new MmsMessage ();
objMmsSlide = new MmsSlide ();
objMmsConstants = new MmsConstants ();
Step 5: Send MMS messages
You can now send MMS messages.
The following code shows how to send a MMS message:
using System;
using System.IO;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using IWshRuntimeLibrary;
using AXmsCtrl;
namespace xmstoolkit
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Image Image1;
protected System.Web.UI.WebControls.Image Image2;
protected System.Web.UI.WebControls.Image Image3;
protected System.Web.UI.WebControls.Image Image4;
protected System.Web.UI.WebControls.Label lblImg1;
protected System.Web.UI.WebControls.Label lblImg2;
protected System.Web.UI.WebControls.Label lblImg3;
protected System.Web.UI.WebControls.Label lblImg4;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.TextBox txtFrom;
protected System.Web.UI.WebControls.TextBox txtSubject;
protected System.Web.UI.WebControls.TextBox txtTo;
protected System.Web.UI.WebControls.TextBox txtResults;
protected System.Web.UI.WebControls.TextBox txtPin;
protected System.Web.UI.WebControls.Label lblFrom;
protected System.Web.UI.WebControls.Label lblTo;
protected System.Web.UI.WebControls.DropDownList cbCountries;
protected System.Web.UI.WebControls.DropDownList cbDevice;
protected System.Web.UI.WebControls.DropDownList cbImage;
protected System.Web.UI.WebControls.Button btnSend;
protected System.Web.UI.WebControls.DropDownList cbProviders;
protected System.Web.UI.WebControls.TextBox txtMessage;
protected System.Web.UI.WebControls.Table Table1;
public MmsProtocolMm1 objMm1Protocol;
public MmsMessage objMmsMessage;
public MmsSlide objMmsSlide;
public MmsConstants objMmsConstants;
private void Page_Load(object sender, System.EventArgs e)
{
//Create the xmstoolkait objects
objMm1Protocol = new MmsProtocolMm1();
objMmsMessage = new MmsMessage();
objMmsSlide = new MmsSlide();
objMmsConstants = new MmsConstants();
//Display the <xmstoolkitinstalldir>\Providers\Mms\Mm1 directory
listDirectory();
//display the selected country and providers:
cbCountries_Change(null, null);
//Display the connected devices
cbDevice.Items.Clear();
int intDevices = objMm1Protocol.GetDeviceCount();
if( intDevices == 0 )
{
//show "no devices....
cbDevice.Items.Insert(0, "No devices installed...");
}
for(int i = 0; i < intDevices; i++)
{
//display the devices
cbDevice.Items.Insert(i, objMm1Protocol.GetDevice(i));
}
}
private void cbCountries_Change(object sender, System.EventArgs e)
{
//Set the selected value
string strSelectedCountry = Request["cbCountries"];
if(strSelectedCountry != null)
{
cbCountries.Items.FindByValue(strSelectedCountry).Selected = true;
listProviders();
}
string strProvider = Request["cbProviders"];
if(strProvider != null)
{
object objProvider;
objProvider = cbProviders.Items.FindByValue(strProvider);
if(objProvider != null)
{
cbProviders.Items.FindByValue(strProvider).Selected = true;
}
}
}
private string installdir()
{
/* The installationfolder of the SMS and MMS Toolkit can be
* in the register, just add \Providers\Mms\Mm1 and you have
* the folder which contains the mm1 configuration
* files */
string strRegKey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveXperts\\SMS and MMS Toolkit\\InstallRoot";
WshShell objWshShell;
objWshShell = new WshShell();
return objWshShell.RegRead(strRegKey).ToString() + "\\Mmsc\\Mm1";
}
private void listDirectory()
{
/* The toolkit contains a configuration file for each
* provider we know in countries, these can be found in
* the installationdirectory \Providers\Mms\Mm1. Every folder
* reprisents a country and the subfolders reprisent
* the providers */
//Declare and create the folder-array
int intLenght = Directory.GetDirectories(installdir()).Length;
object[] arrDir;
arrDir = new object[intLenght];
arrDir = Directory.GetDirectories(installdir());
//prepare the combobox for data
cbCountries.Items.Clear();
//fill in the combobox
for(int i = 0; i < intLenght; i ++)
{
string strDir = arrDir[i].ToString();
strDir = strDir.Replace(installdir(), "");
strDir = strDir.Replace("\\", "");
cbCountries.Items.Insert(i, strDir);
}
}
private void listProviders()
{
/* The MM1 file which are going to be displayed in this
* function reprisent a provider each. The MM1 file
* contains the proper settings for the provider, those
* settings can be set manually if that's desired */
// Declare the objects and variables and get the files
object[] arrFiles;
string strSelectedCountry = installdir() + "\\" + cbCountries.SelectedItem.Value;
int intLength = Directory.GetFiles(strSelectedCountry).Length;
arrFiles = new object[intLength];
arrFiles = Directory.GetFiles(strSelectedCountry);
// Before entering the data, clear the current list first
cbProviders.Items.Clear();
// Insert the providers into the providers drop down menu
for(int i = 0; i < intLength; i++)
{
string strProvider = arrFiles[i].ToString();
strProvider = strProvider.Replace(strSelectedCountry, "");
strProvider = strProvider.Replace("\\", "");
strProvider = strProvider.Replace(".mm1", "");
cbProviders.Items.Insert(i, strProvider);
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnSend.Click += new System.EventHandler(this.btnSend_Click);
this.Load += new System.EventHandler(this.Page_Load);
this.cbCountries.SelectedIndexChanged += new System.EventHandler(this.cbCountries_Change);
}
#endregion
//this.cbCountries.SelectedIndexChanged += new System.EventHandler(this.cbCountries_Change);
private string ErrorMessage()
{
//generate an error message
string strErrorMessage;
strErrorMessage = objMm1Protocol.LastError.ToString();
strErrorMessage += " : ";
strErrorMessage += objMm1Protocol.GetErrorDescription(objMm1Protocol.LastError);
return strErrorMessage;
}
private void btnSend_Click(object sender, System.EventArgs e)
{
//first clear objMmsMessage
objMmsMessage.Clear();
/* Check if the fields are filled in properly, if a
* field is not filled in properly, you script will
* crash */
if(Request["txtSubject"] != ""){
objMmsMessage.Subject = Request["txtSubject"];
}
if(txtMessage.Text != ""){
objMmsMessage.From = txtFrom.Text;
}
if(txtTo.Text != ""){
objMmsMessage.AddRecipient(txtTo.Text);
}
/* Allways check the last error, add a slide if the
* commands above have executed succesfully. */
if(objMm1Protocol.LastError == 0)
{
objMmsSlide.Clear();
objMmsSlide.Duration = 10;
if(Request["txtMessage"] != ""){
objMmsSlide.AddText(Request["txtMessage"]);
}
}
/* add the image, you need the full path to include
* an image. */
if(objMm1Protocol.LastError == 0)
{
string strImg = "img" + cbImage.SelectedItem.Value + ".gif";
string strLocation = Server.MapPath(strImg).ToString();
object objNull = null;
objMmsSlide.AddAttachment(strLocation, ref objNull);
}
// now add the slide to the message
if(objMm1Protocol.LastError == 0)
{
object objTemp = ( object ) objMmsSlide;
objMmsMessage.AddSlide(ref objTemp);
objTemp = null;
}
/* Your message is now ready, all you need to do
* now, is enter the pincode of your simcard,
* get the right configurationfile and send the
* MMS */
if(objMm1Protocol.LastError == 0)
{
objMm1Protocol.Device = cbDevice.SelectedItem.Value;
objMm1Protocol.EnterPin( txtPin.Text );
}
// Load the configuration file
if(objMm1Protocol.LastError == 0)
{
string strConfigurationFile = installdir().ToString();
strConfigurationFile += "\\" + Request["cbCountries"];
strConfigurationFile += "\\" + cbProviders.SelectedItem.Value;
strConfigurationFile += ".mm1";
objMm1Protocol.ProviderLoadConfig( strConfigurationFile );
objMm1Protocol.Connect();
}
// Send the message
if(objMm1Protocol.LastError == 0)
{
object objTemp;
objTemp = ( object ) objMmsMessage;
objMm1Protocol.Send(ref objTemp);
objTemp = null;
}
//Display the results
txtResults.Text = ErrorMessage();
//Disconnect and clear
objMm1Protocol.Disconnect();
objMm1Protocol.Clear();
}
}
}
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.
NOTE: Demo Projects are created with Microsoft Visual Studio 2003
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 2003.
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.
The ActiveXperts SMS and MMS Toolkit is a SMS development component (SDK). This control can be used by any Windows development platform,
including Visual Basic .NET, Visual CSharp .NET,
ASP .NET (VB,CS),
ASP,
Visual Basic,
Visual Basic for Applications (VBA),
Visual Studio/Visual C++,
Borland Delphi and
C++ Builder,
PHP,
ColdFusion,
HTML,
VBScript and any other ActiveX/COM compliant platform. The SMS and MMS Toolkit is an ActiveXperts Software B.V. Product.
|