Friday, January 15, 2010

Sending SMS using ASP.NET

What are the ways in which one can send SMS?


•Using a GSM modem: Better when one wants to implement offline applications and a very small number of SMS go every minute, usually few 10s.

•Using web service: Better when it is an online application and a very few number of SMS go every minute, usually few 10s.

•Using endpoints given by service the provider: Better when the number of SMS exceeds a few 100s per minute. Service provider demands a commitment of at least 100,000 SMS per month.

Sending SMS via a webservice or endpoints is simplest. In contrast, sending SMS via GSM modem has a few additional steps to take care of.
You can send SMS text messages using the following code snippet. The code uses a web service that can send an SMS text message to 90% of all mobile phones.


Private Sub SendMessage(ByVal p_sPhoneNumber As String, ByVal p_sMessage

As String, ByVal p_sUsername As String, ByVal p_sPasskey As String)

Dim smsService As New SMSService.SMSMessagingprocessService()

Dim sCountryCodes As String
Try

If smsService.ValidPhoneNumber(p_sPhoneNumber) Then

Dim result As Boolean = smsService.SendMessage(p_sPhoneNumber,

p_sMessage, p_sUsername, p_sPasskey)

If result = True Then

MsgBox("The message was sent",

MsgBoxStyle.Information, "SMS Messaging")

Else

MsgBox("The message could not be sent",

MsgBoxStyle.Information, "SMS Messaging")

End If

End If

Catch ex As SoapException

MsgBox("An exception occured. " & ex.Detail.InnerText,

MsgBoxStyle.Critical, "SMS Messaging")

End Try

End Sub

No comments:

Post a Comment