You are here:
ActiveXperts.com > SMS and MMS Toolkit > How to Use 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 send MMS messages using a connected GSM GPRS/EDGE/UMTS modem.
The following ASP code generates a website where the user can choose a GIF image, and send it as a MMS message to his mobile phone or email address.
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 send a MMS:
<% 'declare the variables Public strSource, objMm1Protocol, objMmsMessage, objMmsSlide, objMmsConstants, strResult page_load '############################################################################### Sub page_load() 'Set some variables strSource = ReadRegistry("HKEY_LOCAL_MACHINE\SOFTWARE\ActiveXperts\SMS and MMS Toolkit\InstallRoot") strSource = strSource + "\Providers\Mms\Mm1" strResult = "" set objMm1Protocol = nothing set objMmsMessage = nothing set objMmsSlide = nothing set objMmsConstants = nothing If request("submitbutton") <> "" Then sendMMS End If End Sub '############################################################################### 'function for reading the registry Function ReadRegistry(strRegKey) Dim WshShell Set WshShell = server.CreateObject("WScript.Shell") ReadRegistry = WshShell.Regread(strRegKey) End Function '############################################################################### 'function for displaying the files Function ViewFiles(strSource, strType) 'declare the variables Dim objFs Dim objFolder 'create the objects Set objFs = Server.CreateObject("Scripting.FileSystemObject") Set objFolder = objFs.GetFolder(strSource) 'display folders If strType = "folders" then 'display other folders For Each objItem In objFolder.SubFolders %> <option value="<% = objItem.Name %>"><% = objItem.Name %></option> <% Next 'display files elseif strType = "files" then 'display all files For Each objItem In objFolder.Files %> <option value="<% = replace(objItem.Name, ".mm1", "") %>"><% = replace(objItem.Name, ".mm1", "") %></option> <% Next End If End Function '############################################################################### 'show the selected dropdown items Function ShowChosenOption(strURLVar, strType) Dim fs Dim file Dim strString file = strSource + "\" + request("country") + "\" + request("provider") + ".mm1" strString = request(strURLVar) set fs=Server.CreateObject("Scripting.FileSystemObject") If strType = "file" Then if fs.FileExists(file) = true and strString <> "" then %> <option value="<% = strString %>"><% = strString %></option> <% End if Elseif strType = "folder" Then if strString <> "" Then %> <option value="<% = strString %>"><% = strString %></option> <% End If End If End Function '############################################################################### 'function for declaring the objects Function createActiveXpertsObjects() If objMm1Protocol is nothing then Set objMm1Protocol = CreateObject ( "ActiveXperts.MmsProtocolMm1" ) Set objMmsMessage = CreateObject ( "ActiveXperts.MmsMessage" ) Set objMmsSlide = CreateObject ( "ActiveXperts.MmsSlide" ) Set objMmsConstants = CreateObject ( "ActiveXperts.MmsConstants" ) End If End Function '############################################################################### 'function to list the devices Function getdevice() createActiveXpertsObjects For i = 0 To objMm1Protocol.GetDeviceCount() - 1 %> <option value="<% = objMm1Protocol.GetDevice(i) %>"><% = objMm1Protocol.GetDevice(i) %></option> <% Next End Function '############################################################################### 'the function to send the mms Function sendMMS() 'create the activexperts variables createActiveXpertsObjects 'declare the variables Dim strMm1 'get the MM1 file strMm1 = strSource + "\" + request("country") + "\" + request("provider") + ".mm1" 'configure the message objMmsMessage.Clear() objMmsMessage.Subject = request("subject") objMmsMessage.AddRecipient( request("phonenumber") ) 'create a slide objMmsSlide.Clear() objMmsSlide.Duration = 10 objMmsSlide.AddAttachment( Server.MapPath(".") + "\" + request("img") ) objMmsSlide.AddText( request("text") ) 'add a slide objMmsMessage.AddSlide( objMmsSlide ) 'fill in the device If objMm1Protocol.LastError = 0 then objMm1Protocol.Device = request("device") End if 'enter the pincode If request("pin") <> "" and objMm1Protocol.LastError = 0 then objMm1Protocol.EnterPin(request("pin")) End If 'load the configuration file and connect to the server If objMm1Protocol.LastError = 0 then objMm1Protocol.ProviderLoadConfig( strMm1 ) objMm1Protocol.Connect() End If 'send the mms If objMm1Protocol.LastError = 0 then objMm1Protocol.Send ( objMmsMessage ) End If strResult = objMm1Protocol.LastError & " : " & objMm1Protocol.GetErrorDescription(objMm1Protocol.LastError) 'disconnect objMm1Protocol.Disconnect() End Function %> <html> <head> <title>ActiveXperts SMS and MMS Toolkit sample in ASP</title> <style type="text/css"> <!-- select{ width: 300px; border: 1px solid black; font-family: verdana; font-size: x-small; color: black; } input{ width: 300px; border: 1px solid black; font-family: verdana; font-size: x-small; background-color: white; color: black; } div{ width: 300px; border: 1px solid black; } input.radio{ height: 39px; width: 20; border: 0px solid black; font-family: verdana; font-size: x-small; background-color: white; color: black; } table{ width: 562px; border: 1px solid black; font-family: verdana; font-size: x-small; color: black; } h2{ font-family: verdana; font-weight: bold; color: black; } --> </style> </head> <body> <center> <h2> ActiveXperts SMS and MMS Toolkit sample<br> in ASP </h2> <form name=mmsform method="get"> <input type=hidden name="action" value="ok"> <table> <tr> <td>Select your device<font color=red>*</font>:</td> <td> <select name=device> <% getdevice() %> </select> </td> </tr> <tr> <td>Type down your pincode:</td> <td><input type=text name=pin value="<% = request("pin") %>"></td> </tr> <tr> <td>Select your country<font color=red>*</font>:</td> <td> <select name="country" onchange="submit();"> <% ShowChosenOption "country", "folder" %> <% viewFiles strSource, "folders" %> </select> </td> </tr> <tr> <td>Select your provider<font color=red>*</font>:</td> <td> <select name="provider"> <% if request("country") <> "" then %> <% strSource = strSource + "\" + request("country") %> <% ShowChosenOption "provider", "file" %> <% viewFiles strSource, "files" %> <% end if %> </select> </td> </tr> <tr> <td>Phone number<font color=red>*</font>:</td> <td><input type=text name=phonenumber value="<% = request("phonenumber") %>"></td> </tr> <tr> <td>From:</td> <td><input type=text name=from value="<% = request("from") %>"></td> </tr> <tr> <td>Subject:</td> <td><input type=text name=subject value="<% = request("subject") %>"></td> </tr> <tr> <td valign=top>Select the image you want to send<font color=red>*</font>:</td> <td><div><input type=radio class=radio name=img value="img1.gif"><img src="img1.gif" alt=""></div></td> </tr> <tr> <td> </td> <td><div><input type=radio class=radio name=img value="img2.gif"><img src="img2.gif" alt=""></div></td> </tr> <tr> <td> </td> <td><div><input type=radio class=radio name=img value="img3.gif"><img src="img3.gif" alt=""></div></td> </tr> <tr> <td> </td> <td><div><input type=radio class=radio name=img value="img4.gif"><img src="img4.gif" alt=""></div></td> </tr> <tr> <td>Message text:</td> <td><input type=text name=text value="<% = request("text") %>"></td> </tr> <tr> <td> </td> <td><input name=submitbutton type=submit value="Send MMS" onclick="alert('Please wait a moment...')"></td> </tr> </table> </form> <table> <tr> <td><b>Result</b>: <% = strResult %></td> </tr> </table> </center> </body> </html>
You can find the sample images used in this sample below:
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.