You are here:
ActiveXperts.com > SMS and MMS Toolkit > How to Use MMS Toolkit > SOAP (MM7) > ASP.NET (C#)
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:
using AXmsCtrl;
In your Main function, declare and create the following objects:
public MmsProtocolMm7 objMmsProtocolMm7; public MmsMessage objMmsMessage; public MmsSlide objMmsSlide; public MmsConstants objMmsConstants; objMmsProtocolMm7 = 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.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 AXmsCtrl;
namespace smspagercsharp
{
/// <summary>
/// Summary description for MmsMm7Form.
/// </summary>
public class MmsMm7Form : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox ctlURL;
protected System.Web.UI.WebControls.CheckBox ctlUseSSL;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.Label Label5;
protected System.Web.UI.WebControls.TextBox ctlResult;
protected System.Web.UI.WebControls.Label Label7;
protected System.Web.UI.WebControls.Button ctlSendMessage;
protected System.Web.UI.WebControls.TextBox ctlAttachment;
protected System.Web.UI.WebControls.Label Label14;
protected System.Web.UI.WebControls.TextBox ctlMSG;
protected System.Web.UI.WebControls.Label Label6;
protected System.Web.UI.WebControls.TextBox ctlSubject;
protected System.Web.UI.WebControls.Label Label13;
protected System.Web.UI.WebControls.TextBox ctlSender;
protected System.Web.UI.WebControls.Label Label12;
protected System.Web.UI.WebControls.TextBox ctlRecipient;
protected System.Web.UI.WebControls.Label Label9;
protected System.Web.UI.WebControls.TextBox ctlAccount;
protected System.Web.UI.WebControls.TextBox ctlPassword;
protected System.Web.UI.WebControls.Label Label1;
private MmsProtocolMm7 objMm7Protocol = null;
private MmsMessage objMmsMessage = null;
private MmsConstants objConstants = null;
private void Page_Load(object sender, System.EventArgs e)
{
objMm7Protocol = new MmsProtocolMm7();
objMmsMessage = new MmsMessage();
objConstants = new MmsConstants();
if (! IsPostBack)
{
ctlUseSSL.Checked = false;
ctlAttachment.Text = "C:\\Windows\\system32\\clock.avi";
}
}
private void UpdateResult(System.Int32 numResult)
{
ctlResult.Text = numResult.ToString() + ": " + objMm7Protocol.GetErrorDescription(numResult);
}
#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.ctlSendMessage.Click += new System.EventHandler(this.ctlSendMessage_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void ctlSendMessage_Click(object sender, System.EventArgs e)
{
MmsSlide objSlide = new MmsSlide();
MmsMessage objMessage = new MmsMessage();
object obj = null;
objSlide.Clear();
objSlide.AddText(ctlMSG.Text);
objSlide.AddAttachment(ctlAttachment.Text, ref obj);
//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;
obj = objSlide;
objMessage.AddSlide ( ref obj );
objMm7Protocol.Clear();
objMm7Protocol.ProviderURL = ctlURL.Text;
objMm7Protocol.ProviderAccount = ctlAccount.Text;
objMm7Protocol.ProviderPassword = ctlPassword.Text;
objMm7Protocol.ProviderUseSSL = ctlUseSSL.Checked ? -1 : 0;
// objMm7Protocol.LogFile = "c:\\mmsmm7.log";
// Send
obj = objMessage;
objMm7Protocol.Send (ref obj );
UpdateResult( objMm7Protocol.LastError );
}
}
}
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.