SMS is capable of delivering numerous data services to wireless devices, including voice-mail alerts, fax services, ring tones, games etc. A SMS may also be a TMS (Text-Messaging service). A wireless text message is a short string of up to 256 characters that can be sent to a mobile device.
Though the text messaging service was initially used with PAGER devices that support alpha-numeric numbers, it has found a place in the mobile phones also.
Many mobile wireless carriers have made it extremely difficult for developers to get into knowledge source of SMS and its features. They use different modes of handling SMS messages for many reasons. One of the reason is that the cost involved for the very message itself. Some carriers develop API for SMS that can send or receive SMS using the TCP/IP. Some others use protocols like Simple Network Paging Protocol (SNPP), the Wireless Communication Transport Protocol (WCTP), and the Short Message Peer to Peer (SMPP). Some carriers now expose a Simple Mail Transport Protocol (SMTP), an e-mail interface to send short text messages. In this case, the e-mail address will be the device's phone number or pager identification number, along with the wireless carrier's special domain. For example, a phone with Reliance service will have an e-mail address of 3135551212@mobile.Reliance.net.
Alternatively, there are a few mobile phone web sites that allow you to send/receive an SMS using their web site. You can develop a web page in ASP.NET that can be posted to that site for providing SMS services to your users. In India, , ,
, are few websites that offer the SMS and related services for corporate and high volume SMSC links using SMPP (Short Message Peer to Peer) communication protocol.
A SMSC (Short Message Service Center) regulates the message transfer to and from the mobile phones in GSM-networks. This includes not only short text messages but also fax, voice- or e-mails. It delivers the messages, temporarily stores them in case the respective recipient is currently not available and takes care of charging. There is at least one SMSC per network.
The third option is considering a subscription to a SMS webservice using which you can send or receive SMS in your application. Go to
GPRS facilitates continuous wireless connection to data networks and access to your favorite information and entertainment services. It allows mobile phones to be used for sending and receiving data over an Internet Protocol (IP)-based network. Besides SMS, other service protocols like WAP, MMS, SMS, Java and the PC dial-up (for example, Internet and e-mail) are also supported by GPRS.
Unlike SMS gateway services, Internet email services stores the messages using mailbox services. The emails are actually stored and the user gets a notification on their mobile phone and can then retrieve the full email by dialing in to collect it, forward it, and so on. Gateway services offers a wireless email platform wherein it simply translates the message from SMTP(the Internet email protocol) into SMS and sends to the SMS Center.
Most of the times, on receiving a new email, Internet email users do not get notifications on their mobile phones. They need to dial in periodically to check their mailbox. However, we can link the Internet email system with an alert mechanism such as SMS or GPRS, and users can be notified when a new email is received.
Mobile applications are of two types: Web-based and device based.
Web based mobile applications run on the server, typically the Web server, and is accessed by mobile devices through the Internet and SMS services provided by Internet Email messages.
Device specific mobile applications are standalone applications running on the devices itself, with or without Internet access. For this type of application, Microsoft provides a scaled-down version of the .NET Framework—the .NET Compact Framework (.NET CF).
.NET Compact Framework applications target devices like Pocket PCs, Smart Phones, PDAs. It is based on Windows CE. The core set of functions for smart-device systems and applications are available in COREDLL.DLL. It also has the following dlls:
AYGShell.dll – Pocket PC shell functions
CommCtrl.dll – Common control lib
WinSock.dll – Windows Sockets
Phone.dll – High level phone control
SMS.dll – SMS messaging API
Using the P/Invoke support available in .NET CF for calling Win32 API functions in unmanaged dlls, we can send SMS from a C# or VB.NET CF application.
SmsOpen function opens the SMS messaging component.
HRESULT SmsOpen (
const LPCTSTR ptsMessageProtocol,
const DWORD dwMessageModes,
SMS_HANDLE* const psmshHandle,
HANDLE* const phMessageAvailableEvent);
ptsMessageProtocol is a string denoting that SMS protocol to use. dwMessageModes specifies whether we want to be in send or receive mode.
psmshHandle is a pointer to the handle of the SMS session and is valid only if the function returns properly. phMessageAvailableEvent is the handle to a Win32 event handle that can be used to determine when the next message is available to be read.
Using the DllImport attribute in the System.Runtime.InteropServices namespace, we can declare the functions in our code.
private static extern IntPtr SmsOpen(String ptsMessageProtocol,
IntPtr dwMessageModes, ref IntPtr psmshHandle, IntPtr
SmsSendMessage function sends the message to a mobile number.
HRESULT SmsSendMessage (
const SMS_HANDLE smshHandle,
const SMS_ADDRESS * const psmsaSMSCAddress,
const SMS_ADDRESS * const psmsaDestinationAddress,
const SYSTEMTIME * const pstValidityPeriod,
const BYTE * const pbData,
const DWORD dwDataSize,
const BYTE * const pbProviderSpecificData,
const DWORD dwProviderSpecificDataSize,
const SMS_DATA_ENCODING smsdeDataEncoding,
const DWORD dwOptions,
SMS_MESSAGE_ID * psmsmidMessageID);
smshHandle is the handle returned in psmshHandle by SmsOpen. psmsaSMSCAddress is an optional parameter specifying which SMS Message Center is to be used. If NULL is used, the user's default SMSMC will be used.
psmsaDestinationAddress is where the message is to be delivered. pstValidityPeriod breaks from the standard SYSTEMTIME structure in that it is the amount of time past sending of an SMS during which the message still is considered valid.
pbData is the byte representation of the message's data portion. This can be NULL.
dwDataSize is the size in bytes of the message's data portion. pbProviderSpecificData is additional information required by some providers to allow an SMS to transmit correctly. dwProviderSpecificDataSize is the size in bytes of the previously mentioned field.
smsdeDataEncoding is an option found within the SMS_DATA_ENCODING enumeration detailed above. dwOptions are (currently) two flags that will fail an SMS after one attempt or will allow it to be redelivered until the router gives up. psmsmidMessageID will be non-null if this function returns successfully.
In our managed code, we use it as
private static extern IntPtr SmsSendMessage(IntPtr smshHandle, IntPtr
psmsaSMSCAddress, IntPtr psmsaDestinationAddress, IntPtr
pstValidityPeriod, byte pbData, IntPtr dwDataSize, byte
pbProviderSpecificData, IntPtr dwProviderSpecificDataSize,
SMS_DATA_ENCODING smsdeDataEncoding, IntPtr dwOptions, IntPtr
SmsClose function closes an SMS message service request.
HRESULT SmsClose (
const SMS_HANDLE oCommandBarPopup);
In our code we declare it as
private static extern IntPtr SmsClose(IntPtr smshHandle);
Private void SendMessage(string MobileNumber, string FromEmailAddress, string Message)
localhost.SendSMS smsService = New localhost.SendSMS();
bool result = smsService.SendMessage(someMobileNumber,
if (result == True)
MessageBox.Show("The message was sent", "SMS Messaging");
MessageBox.Show("The message was not sent", "SMS Messaging");
catch (SoapException ex)
MessageBox.Show("An exception occured. " & ex.Detail.InnerText, "SMS Messaging");
If you are developing a mobile based SMS service, you need to rely on SMS gateway software components or you can make use of existing webservice which uses them. There is another finest way of providing SMS capability to your application that uses the AT commands which comes as a variety of sets for different mobile devices. This is not discussed in this article.
If you are developing a device based SMS service application, you can go for .NET compact framework that is being shipped with Visual Studio .NET 2003/2005 or you can download it from the internet. Here again, most of the dll components you need for developing SMS services are available with Windows CE 4.2/5.0 SDK toolkit, not available with .NET CF.
Hope you enjoyed reading this article. If you have any comments or suggestions, please feel free to contact me at .
Article ID: 555578 - Last Review: Feb 14, 2017 - Revision: 1