5,699,997 members and growing! (20,505 online)
Email Password   helpLost your password?
Web Development » ASP.NET » Samples     Intermediate

Sending SMS using .NET through Web service

By Manoj Kumar C

This article will help to know how to use web service in .NET.
C++, C#.NET 1.1, Win2K, WinXP, Win2003, Windows, .NET, ASP.NET, MFC, Visual Studio, VS.NET2003, Dev

Posted: 4 Jun 2004
Updated: 4 Jun 2004
Views: 200,136
Bookmarked: 111 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
47 votes for this Article.
Popularity: 4.63 Rating: 2.77 out of 5
18 votes, 38.3%
1
6 votes, 12.8%
2
7 votes, 14.9%
3
7 votes, 14.9%
4
9 votes, 19.1%
5

Sample Image - SendingSMS.gif

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 services in .NET, and also you will get some information about SMS, GPRS etc. This web service will help you give a notification if the service is unable to deliver.

How does it work?

Initially, when undergoing this study, I thought sending SMS to different services will be a problem. For sending SMS, we have to tie up with all the services which is not possible at all. While studying this, I learned most of the services provide 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 a little easier. After that, I thought about 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 it in the upcoming paragraphs.

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 their 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 tied up with ICQ instant messaging service, it maked our work easier. With the help of this web service, we can 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 Web Service Definition Language (WSDL) link for sending SMS:

Here, I m attaching the sample code for sending SMS.

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;
}

In the above code, SendSMSToIndia() method will get the three parameters: mobile number, email address, and message text. And sendSMS() will get the four parameters: email address, country code, mobile number and message text. Click here to test the page.

The most important feature is, it will give mail alert if the SMS is not send to the user. But it will not support all the services which have GPRS facilities.

Happy coding!!!

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

About the Author

Manoj Kumar C


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
Occupation: Web Developer
Location: United States United States

Other popular ASP.NET articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 109 (Total in Forum: 109) (Refresh)FirstPrevNext
Generalproject [modified]memberjames bond 0093:08 4 Nov '08  
GeneralNot workingmemberdileepp0:43 21 Oct '08  
GeneralHi friend can you contact me.membersriharishine3:16 26 Sep '08  
Generalit seems simplememberMember 32647210:06 18 Sep '08  
GeneralIts Notworkingmembersriharshagurram21:57 15 Sep '08  
GeneralSend SMS is not workingmemberid.anju20:55 1 Sep '08  
Generalsweet kissmembersanjali223:28 23 Aug '08  
GeneralRe: sweet kissmemberpavankumarchakilam1:02 20 Oct '08  
GeneralYour webservice doesnt send messages at allmemberAbhishek sur0:05 4 Aug '08  
Generalgetting error in applicationmemberkittu0:56 31 Jul '08  
Generalyour project could not work in India... (suggest me... if it is possiable..>>>membergirish22222:24 4 Jun '08  
GeneralNot Working...memberDipak Salve5:00 30 May '08  
Questionmobile smsmemberMember 44137292:19 28 May '08  
Generalplz give replymemberkalyanapu1:33 17 May '08  
QuestionHELP MEmemberpankaj29819:58 12 May '08  
Generalchutiya banayamemberMember 45323122:02 28 Apr '08  
QuestionSend sms is not workingmemberShaikh Ahmed4:11 25 Apr '08  
Generali love youmembersajjad baba11:34 17 Apr '08  
Generalsending smsmemberPraveenSinha2:21 3 Apr '08  
Generalhelp mememberkalyanapu1:36 17 May '08  
Generalsend a message to mobile using application(vb.net)memberbhavsar3:02 24 Mar '08  
Questionhow to send a registration form's details to my email?memberarchan19:40 13 Mar '08  
AnswerRe: how to send a registration form's details to my email?memberMember 26816610:46 31 Jul '08  
Questionproblem to send messagemembersathishsirikonda0:10 11 Mar '08  
GeneralRe: problem to send messagememberArunpaulson0:04 13 Mar '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 4 Jun 2004
Editor: Smitha Vijayan
Copyright 2004 by Manoj Kumar C
Everything else Copyright © CodeProject, 1999-2008
Web20 | Advertise on the Code Project