To send SMS through Web services using ASP.NET coding

5 pts.
Tags:
ASP.NET
C#
Mobile development
Mobile messaging
SMS Messages
Web services
Is it Possible to send a sms to a mobile phone using asp.net visual c# coding through web service. If it is,please send me the procedure to do that

Answer Wiki

Thanks. We'll let you know when a new response is added.

You sure can and it is similar to sending an email using a normal smtp:

<%
‘##################################################
‘# 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
%>

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Spiritssoft
    For Send SMS Through Code: C#.net: Step 1: Add Web Reference : http://www.spiritssoft.com/webservice/sendway2sms.asmx Step 2: Add This "using com.spiritssoft.www;" Step 3: Create a Object "SendWay2Sms smsobj = new SendWay2Sms();" Step 4: string strResult = smsobj.sendSmsSpiritsSoft("UserName", "Password", "Number", "message"); strResult : Recieving the Result from Webservice Note: - For Group SMS , Number seperated by commas(,). - Message should be Only 125 characters, - If No username , password form way2sms.com it will send message through Spirits Soft Technology Default Number. From : Spirits Soft Technology www.spiritssoft.com
    10 pointsBadges:
    report
  • Ajay0178
    I got error :startindex can not be less zero
    10 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following