You are here:
ActiveXperts.com > SMS and MMS Toolkit > How to Use MMS Toolkit > SMTP (MM4) > ASP 2.x
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 projects.
Download the SMS and MMS Toolkit from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.
First, create a new directory on the IIS Server's file system. This directory will hold the ASP later on.
From the 'Start menu', click on 'Administrative Tools' and click on 'Internet Information Services (IIS) Manager'. Right-click on the 'Web Sites' container and choose 'New->Web Site':
(Click on the picture to enlarge)
The 'Web Site Creation Wizard' is shown, guiding you thorugh the process of creating a new web site. Provide all necessary information:
You're now able to write an ASP script to send MMS content using the ActiveXperts SMS and MMS Toolkit.
Create a new ASP script called DEFAULT.ASP in the directory that was created in Step2, using your favorite editor. On top of the ASP code, insert the following lines to declare the MMS objects:
<% Dim objMmsConstants Dim objMm4Protocol Dim objMmsMessage Dim objMmsSlide %>
Insert the following lines to create the objects:
<% Set objMmsConstants = Server.CreateObject ( "ActiveXperts.MmsConstants" ) Set objMm4Protocol = Server.CreateObject ( "ActiveXperts.MmsProtocolMm4" ) Set objMmsMessage = Server.CreateObject ( "ActiveXperts.MmsMessage" ) Set objMmsSlide = Server.CreateObject ( "ActiveXperts.MmsSlide" ) %>
Now, test if your new web site is working well with the SMS and MMS Toolkit using your browser. If you are using Microsoft Internet Explorer, it is recommended to disable friendly error message because this default setting doesn't show any ASP error message, making it hard to debug if there are any problems:
Now, use the following piece of code in your DEFAULT.ASP page:
<%
Dim objMmsConstants
Dim objMm4Protocol
Dim objMmsMessage
Dim objMmsSlide
%>
<%
Set objMmsConstants = Server.CreateObject ( "ActiveXperts.MmsConstants" )
Set objMm4Protocol = Server.CreateObject ( "ActiveXperts.MmsProtocolMm4" )
Set objMmsMessage = Server.CreateObject ( "ActiveXperts.MmsMessage" )
Set objMmsSlide = Server.CreateObject ( "ActiveXperts.MmsSlide" )
%>
<html>
<head>
<title>MMS Toolkit Demo</title>
</head>
<body>
MMS Toolkit version: <% = objMm4Protocol.Version %><br>
MMS Toolkit expiration date: <% = objMm4Protocol.ExpirationDate %><br>
</body>
</html>
And test it with your favorite browser. The result should be like this:
(Click on the picture to enlarge)
<%@ CodePage=65001%>
<% Option Explicit %>
<object runat="server" progid="ActiveXperts.MmsProtocolMm4" id="objMm4Protocol"> </object>
<object runat="server" progid="ActiveXperts.MmsMessage" id="objMessage"> </object>
<object runat="server" progid="ActiveXperts.MmsSlide" id="objSlide"> </object>
<object runat="server" progid="ActiveXperts.MmsConstants" id="objConstants"> </object>
<html>
<head>
<title>MMS via MM4 - ASP Sample</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<style>
.clbody {
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:9pt;
font-weight:normal;
}
.clfooter {
font-family:Verdana;
font-size:7pt;
font-weight:normal;
}
h1, .h1 {
width:100%;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:18px;
font-weight:bold;
}
hr, .hr {
color:#b0b0b0;
}
</style>
</head>
<body class="clbody">
<h1>MMS via MM4 - ASP Sample</h1>
<div style="WIDTH:700px">
MM4 requires connectivity to an MMSC through the internet/VPN. The protocol is based on SMTP, messages are MIME encoded.<br>
For more details about using SMS and MMS Toolkit with ASP, <a target="_blank" href="http://www.activexperts.com/support/xmstoolkit#asp">
click here</a>.<br>
</div>
<hr size="1">
<%
Dim numLastError, strLastError, strReply
numLastError = 0
strLastError = ""
strReply = ""
If( Request( "CTL_SEND" ) <> "" ) Then
objSlide.Clear()
objSlide.AddText( Request( "CTL_MESSAGE" ) )
objSlide.AddAttachment Request( "CTL_ATTACHMENT" ) , 0
objMessage.Clear()
objMessage.AddRecipient Request( "CTL_RECIPIENT" ), objConstants.asMMS_RECIPIENT_TO
objMessage.From = Request( "CTL_SENDER" )
objMessage.Subject = Request( "CTL_SUBJECT" )
objMessage.AddSlide(objSlide)
objMm4Protocol.Clear()
objMm4Protocol.ProviderHost = Request( "CTL_HOST" )
objMm4Protocol.ProviderPort = Request( "CTL_PORT" )
objMm4Protocol.ProviderDomain = Request( "CTL_DOMAIN" )
objMm4Protocol.ProviderAccount = Request( "CTL_ACCOUNT" )
objMm4Protocol.ProviderPassword = Request( "CTL_PASSWORD" )
' objMm4Protocol.LogFile = "c:\mmsmm4.log"
objMm4Protocol.Send( objMessage )
numLastError = objMm4Protocol.LastError
strLastError = objMm4Protocol.GetErrorDescription( numLastError )
End If
%>
<form action="default.asp" method="post">
<table class ="clbody" width="700">
<tr>
<td valign="top">Host:</td>
<td valign="top"><input style="width: 200px" type="text" name="CTL_HOST" value=<% If Request( "CTL_HOST" ) = "" Then %>"[Host]"<% Else %><% = Request( "CTL_HOST" ) %><% End If %>>:<input style="width: 30px" type="text" name="CTL_PORT" value=<% If Request( "CTL_PORT" ) = "" Then %>"25"<% Else %><% = Request( "CTL_PORT" ) %><% End If %>></td>
</tr>
<tr>
<td valign="top">Domain:</td>
<td valign="top"><input style="width: 250px" type="text" name="CTL_DOMAIN" value=<% If Request( "CTL_DOMAIN" ) = "" Then %>""<% Else %><% = Request( "CTL_DOMAIN" ) %><% End If %>></td>
</tr>
<tr>
<td valign="top">Account:</td>
<td valign="top"><input style="width: 250px" type="text" name="CTL_ACCOUNT" value=<% If Request( "CTL_ACCOUNT" ) = "" Then %>""<% Else %><% = Request( "CTL_ACCOUNT" ) %><% End If %>></td>
</tr>
<tr>
<td valign="top">Password:</td>
<td valign="top"><input style="width: 250px" type="text" name="CTL_PASSWORD" value=<% If Request( "CTL_PASSWORD" ) = "" Then %>""<% Else %><% = Request( "CTL_PASSWORD" ) %><% End If %>></td>
</tr>
<tr>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">Recipient:</td>
<td valign="top"><input style="width: 250px" type="text" name="CTL_RECIPIENT" value=<% If Request( "CTL_RECIPIENT" ) = "" Then %>"[Recipient]"<% Else %><% = Request( "CTL_RECIPIENT" ) %><% End If %>> <a target="_blank" href="http://www.activexperts.com/support/xmstoolkit?kb=Q5200015#Q5200015">Recipient number format</a></td>
</tr>
<tr>
<td valign="top">Sender:</td>
<td valign="top"><input style="width: 250px" type="text" name="CTL_SENDER" value=<% If Request( "CTL_SENDER" ) = "" Then %>""<% Else %><% = Request( "CTL_SENDER" ) %><% End If %>></td>
</tr>
<tr>
<td valign="top">Subject:</td>
<td valign="top"><input style="width: 250px" type="text" name="CTL_SUBJECT" value=<% If Request( "CTL_SUBJECT" ) = "" Then %>""<% Else %><% = Request( "CTL_SUBJECT" ) %><% End If %>></td>
</tr>
<tr>
<td valign="top">Message:</td>
<td valign="top"><input style="width: 250px" type="text" name="CTL_MESSAGE" value=<% If Request( "CTL_MESSAGE" ) = "" Then %>"[Message]"<% Else %><% = Request( "CTL_MESSAGE" ) %><% End If %>></td>
</tr>
<tr>
<td valign="top">Attachment:</td>
<td valign="top"><input style="width: 250px" type="text" name="CTL_ATTACHMENT" value=<% If Request( "CTL_ATTACHMENT" ) = "" Then %>"C:\Windows\System32\Setup.bmp"<% Else %><% = Request( "CTL_ATTACHMENT" ) %><% End If %>></td>
</tr>
<tr>
<td valign="top"> </td>
<td valign="top"><input size="25" type="submit" value="Send" name="CTL_SEND" style="height: 23px; width: 250px"></td>
</tr>
<tr>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">Result:</td>
<td valign="top"><% = numLastError %>: <% = strLastError %></td>
</tr>
</table>
<br>
<br>
</form>
<hr size="1">
</body>
</html>
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.