Face it. Wireless devices are red hot. For example, the number of mobile phones is double that of PCs and continues to increase; sales of wireless Web devices are expected to grow from $10 billion in 2000 to $73 billion in 2005, according to consultants Strategy Analytics (see http://www.strategyanalytics.com/press/PRCR007.htm). While there are many debates about which wireless services will succeed, Short Message Service (SMS) is one that has already proven to be a winner. According to Logica, a global solutions company, within three years, carriers will be sending up to 200 billion short messages per month, a 170 percent annual increase over current levels (for more, see http://www.logica.com/news/press/pr704.html). At this rate, the average mobile phone user will receive three SMS messages each day.
SMS is capable of delivering numerous data services to wireless devices, including voice-mail alerts, fax services, ring tones, games, and of course, the popular text-messaging service. A wireless text message is a short string of 100 to 256 characters that can be sent to a mobile device. While text messaging has normally fallen within the domain of alphanumeric pagers, it is a surprise to most people that modern mobile phones support text messaging as well.
Even though SMS is in demand, most carriers have made it extremely difficult for developers to tap into its resources. This conflict arises because of the variable costs tied to each message. In most cases, an account with each carrier will be required in order to make an Application Programming Interface (API) via TCP/IP available. Some accepted protocols adopted by carriers include the Simple Network Paging Protocol (SNPP), the Wireless Communication Transport Protocol (WCTP), and the Short Message Peer to Peer (SMPP). These protocols fall outside the scope of this article because it is possible to send SMS using alternative modes.
Solution 1: Send a Text-Message via SMTP
Some carriers now expose a Simple Mail Transport Protocol (SMTP), an e-mail interface to send short text messages. Typically, the e-mail address will be the device's phone number or pager identification number, along with the carrier's special domain. For example, a phone with AT&T service will have an e-mail address of 3135551212@mobile.att.net. Users must be cautious because some carriers, such as Pacific Bell, include the number 1 before the phone number (1 is the country code according to the North American Numbering Plan) in the e-mail address for the device.
The following example uses the DevMailer 1.0 ASP object to handle e-mail, but any SMTP object could easily replace it. (15Seconds offers more on DevMailer at http://www.15Seconds.com/component/pg002059.htm.)
The sms.inc file is a separate code document included with this article. It includes the e-mail interface and some SMS error-checking routines:
<%
'##################################################
'# Requirements: dvmailer.dll
'##################################################
'##################################################
'# Set Global Variables
'##################################################
SMTP_SERVER = "mail.domain.com"
SMTP_SERVER_PORT = 25
'##################################################
'# Function to send the SMS via email
'#
'# Returns True/False whether the email was sent.
'##################################################
Public Function SendSMS(msgToEmailAddress, msgFromEmailAddress, msgSubject, msgText)
' Set the various lengths associated with each carrier
' AT&T
If (InStr(1, msgToEmailAddress, "mobile.att.net") > 1) Then
maxLength = 140
' Nextel
ElseIf (InStr(1, msgToEmailAddress, "messaging.nextel.com") > 1) Then
maxLength = 280
' Sprint PCS
ElseIf (InStr(1, msgToEmailAddress, "messaging.sprintpcs.com") > 1) Then
maxLength = 100
' Default Length
Else
maxLength = 140
End If
' Typically, there are at least two characters of delimiter between the from,
' subject, and text on the screen of the mobile device.
'We must add this into the equation in order to ensure
' the entire message gets sent to the device.
msgLength = len(msgFromEmailAddress & " " & msgSubject & " " & msgText)
' This is here to make sure the message isn't longer than the device supports.
If ( msgLength > maxLength) Then
' Return false
SendSMS = false
Else
' Create DevMailer Object
Set Mailer = CreateObject("Geocel.Mailer")
' Add SMTP server
Mailer.AddServer SMTP_SERVER, SMTP_SERVER_PORT
' Set From
Mailer.FromAddress = msgFromEmailAddress
' Set Subject
Mailer.Subject = msgSubject
' Set Content Type to Text Only
Mailer.ContentType = "text/plain; charset=us-ascii"
' Set the body
Mailer.Body = msgText
' Add recipient
Mailer.AddRecipient msgToEmailAddress, ""
' Send It
SendSMS = Mailer.Send()
End If
End Function
%>
The sendsms.asp will pull in this function and send off a text message.
<!--#include virtual="/sms.inc"-->
<%
msgTo = "3131234567@messaging.sprintpcs.com"
msgFrom = "joelauer@domain.com"
msgSubject = "Hello World"
msgText = "First text-message!!"
'Attempt to send the sms
IsSent = SendSMS(msgTo, msgFrom, msgSubject, msgText)
if IsSent then
Response.Write("SMS successfully sent to " & msgTo)
else
Response.Write("SMS not successfully sent to " & msgTo)
end if
%>
Although this interface draws a quick and dirty solution, sending SMS via e-mail still has many hidden drawbacks, including speed, assurance, error checking, features, and consistency. By its original design, e-mail was not intended to become a quick system. As a result, most text messages that are sent through e-mail experience latency problems ranging from 1 minute to 2 hours. This estimate also assumes that an SMTP server will not go down somewhere along the path of the e-mail. E-mail will not guarantee that the recipient subscribes to text messaging with their phone's normal service plan.
Furthermore, SMS lengths range from 80 to 256 characters. Messages delivered via SMTP will normally omit those parts of the message that carry over the maximum character length. Unfortunately, your code will never discover the discarded parts of your message. The most prominent drawback is the diversity of e-mail formats between various services. In some cases, the Subject field will be used, rather than the Body field. In either case, your code will have to account for this error or else parts of your message will not reach the mobile device. An additional problem with using the e-mail format arises when the From field has already used up 20 to 30 characters in the small, allotted space of 80 to 256. Finally, SMTP does not make available many of the best features specifically available with SMS, such as one-touch callback and presence information (e.g. phone on/off, signal strength).
Solution 2: Send a Text-Message via a Third Party
There are SMS alternatives to SMTP. Third-party solutions include
shrink-wrapped software and application service provider (ASP) gateways. Many third-party ASPs even provide a shrink-wrapped ASP object that will hide the TCP/IP intricacies of interfacing to their gateway. The Simplewire SMS object is one such example. The code below from swsms.asp demonstrates its easy use.
<%
'##################################################
'# Requirements: swsms.dll
'##################################################
' Create the SMS object
Set sms = Server.CreateObject("SimplewireSMS.SMSRequest")
' Set request to message send
sms.setSendPage
' Set properties
sms.setSynch(True)
sms.msgFrom = "Joe"
sms.msgPin = "3135551212"
sms.msgCallbackNum = "3131234567"
sms.msgText = "Hello world with SMS!"
' Send request
Set smsResponse = sms.send
' Error checking
If smsResponse.isSuccess = False Then
Response.Write("SMS was not successfully sent. ")
Response.Write("Error Code: " & smsResponse.errorCode & " - " & smsResponse.errorDesc)
Else
Response.Write("SMS was successfully sent.")
End If
' Cleanup
Set req = Nothing
Set res = Nothing
%>
Summary
Third-party solutions or shrink-wrapped ASP objects provide a simple and easy way to interface to SMS devices. However, most solutions will have licensing and usage fees, since carriers set their final prices. Although SMTP will provide a low-priority path to a set amount of wireless devices, the number of devices supporting e-mail world wide is considerably small. Additionally, there are several masked complications associated with SMTP-delivered text messages. If performance, reliability, and scalability are of utmost importance, then seeking a third-party component may be the best solution for text messaging.
About the Author
Joe Lauer is the founder and president of Simplewire Inc., a Detroit company providing a wireless text-messaging platform to businesses and consumers. Mr. Lauer is an intrinsic software entrepreneur. Previous to founding Simplewire, he held various software engineering and management positions with Rootlevel Inc., a Web application-development company. At Rootlevel, Mr. Lauer led software development on numerous Fortune 500 wireless and client/server initiatives. Mr. Lauer is currently authoring a book on SMS. He can be reached at joelauer@simplewire.com.
Learn how to use .NET to communicate with the X10 Firecracker Home Automation System through a PC's serial port. Then build a mobile Web form to access all X10-enabled appliances from a wireless device. [Read This Article][Top]
In the third and final installment of the Programming for the Palm series, Robert Chartier shows how to create a Windows Installer that will install and register the Palm application and Palm conduit on the target machine. [Read This Article][Top]
In the second part of this three-part series on programming for the Palm, Robert Chartier shows how to work with the Palm synchronization process and how to handle data transferring, importing, and uploading to various destinations using the Palm Conduit Developer Kit and VS .NET. [Read This Article][Top]
The first part of this three part series walks through the process of creating a mobile blog application using a BASIC development environment for Palm OS devices called NS Basic.
Subsequent articles will focus on synchronizing the data to the desktop using C# and creating an installer. [Read This Article][Top]
In the past, developers typically relied on XML and XSLT to create sites that needed to target multiple client platforms. Today, with ASP.NET mobile controls, developers only need to focus on creating one application. In this article, Rob Chartier shows how easy it is to use the ASP.NET mobile controls to create a full-blown wireless portal. [Read This Article][Top]
Learn how to create applications for wireless devices using the Handheld Device Markup Language (HDML) and ASP. Article covers everything from setting the MIME content type for HDML in ASP to passing data between languages to accessing environment variables from ASP. [Read This Article][Top]
Mailing List
Want to receive email when the next article is published? Just Click Here to sign up.