You are here:
ActiveXperts.com > SMS and MMS Toolkit > How to Use SMS and MMS Toolkit > GSM/GPRS (MM1) > 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 objMm1Protocol Dim objMmsMessage Dim objMmsSlide %>
Insert the following lines to create the objects:
<% Set objMmsConstants = Server.CreateObject ( "ActiveXperts.MmsConstants" ) Set objMm1Protocol = Server.CreateObject ( "ActiveXperts.MmsProtocolMm1" ) 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 objMm1Protocol
Dim objMmsMessage
Dim objMmsSlide
%>
<%
Set objMmsConstants = Server.CreateObject ( "ActiveXperts.MmsConstants" )
Set objMm1Protocol = Server.CreateObject ( "ActiveXperts.MmsProtocolMm1" )
Set objMmsMessage = Server.CreateObject ( "ActiveXperts.MmsMessage" )
Set objMmsSlide = Server.CreateObject ( "ActiveXperts.MmsSlide" )
%>
<html>
<head>
<title>MMS Toolkit Demo</title>
</head>
<body>
MMS Toolkit version: <% = objMm1Protocol.Version %><br>
MMS Toolkit expiration date: <% = objMm1Protocol.ExpirationDate %><br>
</body>
</html>
And test it with your favorite browser. The result should be like this:
(Click on the picture to enlarge)
You can now receive MMS messages using a connected GSM GPRS/EDGE/UMTS modem.
The following ASP code generates a website where incoming messages are listed on a webpage.
The demo can be run from a client connecting to the ASP webserver. The client does not need any additional hardware.
The modem has to be connected to the webserver.
The following ASP code shows how to receive MMS messages:
default.asp<% Option Explicit %> <% ' ******************************************************************** ' ' Receive an MMS message through a connected GPRS/UMTS modem. ' ' Note: ' ' The GPRS/UMTS phone or modem must be connected to your PC ' using an USB or serial datacable, IR or BlueTooth. ' ' (c) Copyright 2008 by ActiveXperts Software - www.activexperts.com ' ' ******************************************************************** %> <% ' Create objects Dim objConnection Set objConnection = CreateObject ( "ActiveXperts.MmsProtocolMm1" ) %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>ActiveXperts SMS and MMS Toolkit - Receive MMS Messages</title> <style type="text/css"> <!-- td,body{ font-size: x-small; } --> </style> </head> <body style="font-family: verdana; font-size: x-small;"> <hr size="1" color="#707070"> <p style="font-weight: bold; font-size: 13pt;">ActiveXperts SMS and MMS Toolkit MMS MM1 ASP Sample</p> <p>Receive an MMS message to a recipient through a GSM/GPRS Phone or Modem connected to your PC.</p> <p>For more details about using SMS and MMS Toolkit with ASP, <a target="_blank" href="http://www.activexperts.com/support/kb/index.asp?productcode=004&idcategory=457">click here</a>.</p> <hr size="1" color="#707070"> <form action="receive.asp" method="post"> <table border="0" bgcolor="#f0f0f0"> <tr> <td width="120">Device</td> <td> <select name="Device"> <% Dim arrDevices, strDevice, i arrDevices = getDevices for i = 0 to ubound(arrDevices) strDevice = arrDevices(i) Response.Write "<option value='" & strDevice & "'>" & strDevice & "</option>" & vblf next %> </select> </td> </tr> <tr> <td width="120">APN</td> <td width="450"><input type="text" style="width: 400px;" name="APN"></td> </tr> <tr> <td width="120">APN Account</td> <td width="450"><input type="text" style="width: 400px;" name="APNAccount"></td> </tr> <tr> <td width="120">APN Password</td> <td width="450"><input type="text" style="width: 400px;" name="Password"></td> </tr> <tr> <td width="120">WAP Gateway</td> <td width="450"><input type="text" style="width: 400px;" name="Gateway"></td> </tr> <tr> <td width="120">MMSC</td> <td width="450"><input type="text" style="width: 400px;" name="MMSC"></td> </tr> <tr> <td width="120">Logfile</td> <td width="450"><input type="text" style="width: 400px;" name="Logfile"></td> </tr> <tr> <td width="120">Result</td> <td width="450"></td> </tr> </table> <p><input type="submit" name="SubmitButton" value="Get messages"></p> <hr size="1" color="#707070"> <p style="font-family: verdana;"> This demo uses the ActiveXperts SMS and MMS Toolkit, an <a href="http://www.activexperts.com">ActiveXperts Software</a> product.<br> <a href="../index.htm">Click here</a> to return to the ASP sample menu page.<br> </p> </form> </body> </html> <% ' *************************************************************************** ' Function GetDevices ' *************************************************************************** Function getDevices() Dim nDeviceCount, arrResults() nDeviceCount = objConnection.GetDeviceCount If( nDeviceCount <> 0 ) Then Dim i, nIndex nIndex = objConnection.GetDeviceCount - 1 ReDim arrResults(nIndex) For i = 0 To ( objConnection.GetDeviceCount - 1 ) arrResults(i) = objConnection.GetDevice(i) Next Else Redim arrResults(0) arrResults(0) = "No devices connected to computer." End If getDevices = arrResults End Function %>receive.asp
<% Option Explicit %> <% ' ******************************************************************** ' ' Receive an MMS message through a connected GPRS/UMTS modem. ' ' Note: ' ' The GPRS/UMTS phone or modem must be connected to your PC ' using an USB or serial datacable, IR or BlueTooth. ' ' (c) Copyright 2008 by ActiveXperts Software - www.activexperts.com ' ' ******************************************************************** %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>ActiveXperts SMS and MMS Toolkit - Receive MMS Messages</title> <style type="text/css"> <!-- td,body{ font-size: x-small; } --> </style> </head> <body style="font-family: verdana; font-size: x-small;"> <hr size="1" color="#707070"> <p style="font-weight: bold; font-size: 13pt;">ActiveXperts SMS and MMS Toolkit MMS MM1 ASP Sample</p> <p>Receive an MMS message to a recipient through a GSM/GPRS Phone or Modem connected to your PC.</p> <p>For more details about using SMS and MMS Toolkit with ASP, <a target="_blank" href="http://www.activexperts.com/support/kb/index.asp?productcode=004&idcategory=457">click here</a>.</p> <hr size="1" color="#707070"> <% ReceiveMessages() %> <hr size="1" color="#707070"> <p style="font-family: verdana;"> This demo uses the ActiveXperts SMS and MMS Toolkit, an <a href="http://www.activexperts.com">ActiveXperts Software</a> product.<br> <a href="../index.htm">Click here</a> to return to the ASP sample menu page.<br> </p> </body> </html> <% Sub ReceiveMessages() ' Declare objects Dim objConstants, objMessage, objConnection, objSlide ' Declare variables Dim n, nCount Dim m, nAttachments ' Create objects Set objConnection = CreateObject ( "ActiveXperts.MmsProtocolMm1" ) Set objConstants = CreateObject ( "ActiveXperts.MmsConstants" ) Response.Write( "<table border='0' bgcolor='#f0f0f0'>" & vbLf ) Response.Write( " <tr>" & vbLf ) Response.Write( " <td width='120'>Device</td>" & vbLf ) Response.Write( " <td>" & Request("Device") & "</td>" & vbLf ) Response.Write( " </tr>" & vblf ) objConnection.Device = Request("Device") If( objConnection.Device = "" ) Then Response.Write( " <tr>" & vbLf ) Response.Write( " <td> </td>" & vbLf ) Response.Write( " <td>No TAPI devices available</td>" & vbLf ) Response.Write( " </tr>" & vbLf ) Response.Write( "</table>" ) Exit Sub End If ' Set 'LogFile' objConnection.LogFile = Request("Logfile") ' Set provider properties GPRS APN, WAP Gateway and MMSC Server Address. ' Please check http://www.activexperts.com/mmstoolkit/mmsclist, or ask your provider for ' your provider's settings ' Set APN objConnection.ProviderAPN = Request("APN") ' Set APN Account objConnection.ProviderAPNAccount = Request("APNAccount") ' Set APN Password objConnection.ProviderAPNPassword = Request("Password") ' Set WAP Gateway objConnection.ProviderWAPGateway = Request("Gateway") ' Set MMSC URL objConnection.ProviderMMSC = Request("MMSC") ' Download MMS notifications from SIM card nCount = objConnection.CountReceivedMessages Response.write( " <tr>" & vbLf ) Response.write( " <td width='120'>Counting messages</td>" & vbLf ) Response.write( " <td width='450'>" &_ "Result: " & objConnection.LastError & " (" & _ objConnection.GetErrorDescription ( objConnection.LastError ) & ")" &_ "</td>" & vbLf ) Response.Write( " </tr>" & vblf ) If ( objConnection.LastError <> 0 ) Then Exit Sub End If If ( nCount = 0 ) Then Response.write( " <tr>" & vbLf ) Response.write( " <td width='120'>Messages:</td>" & vbLf ) Response.write( " <td width='450'>No new messages waiting...</td>" & vblf) Response.write( " </tr>" & vbLf ) Response.write( "</table>" & vbLf ) Exit Sub End If objConnection.Connect Response.Write( " <tr>" & vbLf ) Response.Write( " <td width='120'>Connecting</td>" & vbLf ) Response.Write( " <td width='450'>Result: " & objConnection.LastError & " (" &_ objConnection.GetErrorDescription ( objConnection.LastError ) & ")" ) Response.Write( " </tr>" & vbLf ) If ( objConnection.LastError <> 0 ) Then Response.Write("</table>") Exit Sub End If For n = 0 To nCount - 1 On Error Resume Next Set objMessage = objConnection.GetMessage ( n ) On Error Goto 0 If ( objConnection.LastError = 0 ) Then Response.Write( " <tr>" & vbLf ) Response.Write( " <td colspan=2>New MMS message received from: " & objMessage.From & "</td>" & vbLf ) Response.Write( " </tr>" ) On Error Resume Next Set objSlide = objMessage.GetFirstSlide () On Error Goto 0 While ( objMessage.LastError = 0 ) nAttachments = objSlide.CountAttachments () For m = 0 To nAttachments - 1 Response.Write( " <tr>" & vbLf ) Response.Write( " <td width='120'>Attachment found:</td>" & vbLf ) Response.Write( " <td width='450'>" &_ objSlide.GetAttachmentName ( m ) &_ "</td>" & vbLf ) Response.Write( " </tr>" ) Next On Error Resume Next Set objSlide = objMessage.GetNextSlide () On Error Goto 0 WEnd End If Next ' GPRS/UMTS Disconnect objConnection.Disconnect Response.Write( "</table>" ) 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/mobile-messaging-component.