Click here to Skip to main content
15,886,518 members
Articles / Programming Languages / C#
Article

Sending SMS using .NET through a Web service

Rate me:
Please Sign up or sign in to vote.
2.87/5 (87 votes)
7 Jun 20043 min read 1.1M   45.2K   178   266
This article will help you to know how to use web services in .NET

Image 1

Introduction

This article is about sending SMS using .NET through web service. With the help of this article we can easily understand how to use web service in .NET and also you will get some information about SMS, GPRS etc. This web service will help you to give the notification if the service unable to deliver.

How does it work?

Initially when undergoing this study I think sending SMS to different services will be a problem, for sending SMS we have to tie up with all the services it is not possible at all, while studying this most of the services provides GPRS(General Packet Radio Service ) facility. GPRS has more functionality and here we are going to use only one that is Internet email services. So it makes our work little easier. After that I think how to find out the services for that particular mobile number. Now it became very critical, then I found a web service that provides us all the information that we needed. Let we discuss in upcoming paragraph.

What is GPRS?

With GPRS you can enjoy a continuous wireless connection to data networks and access your favorite information and entertainment services. GPRS technology allows mobile phones to be used for sending and receiving data over an Internet Protocol (IP)-based network. GPRS as such is a data bearer that enables wireless access to data networks like the Internet. The applications using GPRS are WAP, MMS, SMS, Java and the PC dial-up (for example, Internet and e-mail).

Internet email services come in the form of a gateway service where the messages are not stored, or mailbox services in which messages are stored. In the case of gateway services, the wireless email platform simply translates the message from SMTP, the Internet email protocol, into SMS and sends to the SMS Center. In the case of mailbox email 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.

Upon receiving a new email, most Internet email users do not currently get notified of this fact on their mobile phone. When they are out of the office, they have to dial in speculatively and periodically to check their mailbox contents. However, by linking Internet email with an alert mechanism such as SMS or GPRS, users can be notified when a new email is received.

For more information about GPRS click here

Using the code

In this article I am using a web service which already exists. Since this web service is tie up with ICQ instant messaging service make our work easier. With the help of this web service we can able to send SMS to various countries like India, US, UK, Malaysia, Japan etc. In this article I have used the web service from www.webservicex.com they are providing Webs Service Definition Language (WSDL) link for sending SMS.

Here I m attaching the sample code for sending SMS.

C#
private void Send_Click(
 object sender, System.EventArgs e)
    {
      try
      {
        SmsTest.net.webservicex.www.SendSMS smsIndia= 
          new SmsTest.net.webservicex.www.SendSMS();
        SmsTest.com.webservicex.www.SendSMSWorld smsWorld =  
          new SmsTest.com.webservicex.www.SendSMSWorld();
        if(rdoType.SelectedValue == "1")
          smsIndia.SendSMSToIndia(txtMobileNo.Text.Trim(), 
            txtEmailId.Text.Trim(), txtMessage.Text);
        else 
          smsWorld.sendSMS(txtEmailId.Text.Trim(), 
           txtCountryCode.Text.Trim(), txtMobileNo.Text.Trim(), 
           txtMessage.Text);
        lblMessage.Visible = true;
        lblMessage.Text="Message Send Succesfully";
      }
      catch(Exception ex)
      {
        lblMessage.Visible = true;
        lblMessage.Text="Error in Sending message"+ex.ToString();
      }
    }

    private void rdoType_SelectedIndexChanged(
     object sender, System.EventArgs e)
    {
      if(rdoType.SelectedValue =="1")
        txtCountryCode.Enabled = false;
      else
        txtCountryCode.Enabled = false;

    }

Conclusion

The most important feature is it will give mail alerts if the SMS is not send to the user. And it will not support all the services which has GPRS facilities.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
I have done Bachelor in Mechanical Engineering. I have strong background in C#, ASP.NET, SQL server 2000. And i also worked in some small application in Mobile.NET and CF.NET

Comments and Discussions

 
AnswerRe: sms not sending Pin
Member 1028126917-Dec-13 23:27
Member 1028126917-Dec-13 23:27 
GeneralMy vote of 1 Pin
Raamcy18-Jan-12 20:53
Raamcy18-Jan-12 20:53 
Generalwebservice is not envoking Pin
Gourav Pravin18-Jan-12 1:24
Gourav Pravin18-Jan-12 1:24 
Questionhh Pin
Sohini Dey219-Jan-12 22:42
Sohini Dey219-Jan-12 22:42 
QuestionCode not working Pin
Razia8615-Dec-11 0:06
Razia8615-Dec-11 0:06 
GeneralMy vote of 5 Pin
mehdi kermani10-Dec-11 0:52
mehdi kermani10-Dec-11 0:52 
QuestionNO Pin
Member 837200426-Nov-11 18:42
Member 837200426-Nov-11 18:42 
QuestionNot wrking Pin
arun.m.mr14-Nov-11 19:26
arun.m.mr14-Nov-11 19:26 
QuestionIt is not working..Plz update anyone.. Pin
abintj13-Oct-11 19:16
abintj13-Oct-11 19:16 
QuestionRuns very fine... but sms not sends.... Pin
ganesh mahajan11-Sep-11 23:11
ganesh mahajan11-Sep-11 23:11 
QuestionIts Not Worked Pin
Mohandas P G24-Aug-11 18:56
Mohandas P G24-Aug-11 18:56 
Questionhai Pin
r.k.mukil29-Jun-11 4:10
r.k.mukil29-Jun-11 4:10 
GeneralMy vote of 1 Pin
PankajSingh223-May-11 23:51
PankajSingh223-May-11 23:51 
GeneralPlease remove this Pin
mjeyakumar18-May-11 1:48
mjeyakumar18-May-11 1:48 
GeneralSending SMS via ICQ open c# code Pin
Ofer Fridman10-May-11 21:37
Ofer Fridman10-May-11 21:37 
GeneralMy vote of 1 Pin
himanshu_sgrr5-May-11 21:48
himanshu_sgrr5-May-11 21:48 
Generaliuio 7u 7 Pin
NABAMITA SARKAR14-Apr-11 20:46
NABAMITA SARKAR14-Apr-11 20:46 
Generalcode not working... Pin
chandrashekhar bisht21-Mar-11 3:03
chandrashekhar bisht21-Mar-11 3:03 
GeneralMy vote of 1 Pin
yuvan616-Mar-11 20:26
yuvan616-Mar-11 20:26 
Generalcode is not working. Pin
niravsahayata2-Mar-11 21:33
niravsahayata2-Mar-11 21:33 
Generaltestsms Pin
kanzariya23-Jan-11 12:04
kanzariya23-Jan-11 12:04 
QuestionSending sms through mobile connected with pc Pin
Edward0913-Jan-11 0:11
Edward0913-Jan-11 0:11 
Generalit is not working Pin
ajeetsinghsachan24-Dec-10 1:07
ajeetsinghsachan24-Dec-10 1:07 
QuestionCan you help me Pin
showki798-Nov-10 19:24
showki798-Nov-10 19:24 
QuestionDoes not get SMS????????????????????????????????????? Pin
Naveen Kumar Verma25-Oct-10 2:12
Naveen Kumar Verma25-Oct-10 2:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.