Sending SMS through Asp.net using C#


There are some Developers asking in Forum discussions how to send a Short Message service (i.e. SMS) in asp.net There are certain ways to send an SMS what are the ways to Send an SMS. I will illustrate here with detailed description and i will write Code snippets for url (i.e. HTTP) model of sending SMS.

There are some Developers asking in Forum discussions how to send a Short Message service (i.e. S.M.S) in asp.net There are certain ways to send an S.M.S . What are the ways to Send an S.M.S. I will illustrate here with detailed description and write the Code snippets URL (i.e. HTTP) model of sending SMS.

In General Short Message Service (SMS) can be send in two ways one is Protocol base through SMPP (short message Peer to Peer ) and Another is URL based . The discrepancy between URL and Protocol based is that url way of sending SMS have no Acknowledgement. You are unable to know whether the SMS is reached to intended user where as SMS based Short Message Peer to Peer (SMPP) Protocol way of sending will route your message of your Network Service and you will have an acknowledgement of the SMS recieved through Short Message Service Center(SMSC) but its a Cost effective process.

Here we will know how to send an Short Message Service through URL based which is Using a WebClient Class

The WebClient class will be available in using SYSTEM.NET

The Upload String Method will take url as a String



Using System.Net;



WebClient wc =new WebClient();

It is an Optional to add Header when you are sending Message as urlEncoded Other than UrlEncoded it is Mandatory to specify.

wc .Headers.Add("Content-"application/x-www-form-urlencoded"")

wc .QueryString.Add("USERNAME", "yourUserName");

wc .QueryString.Add("PASSWORD", "YourPassword");

wc .QueryString.Add("DESTADDR", "Your Mobile Number");

wc .QueryString.Add("MESSAGE", "This is the test message");

string baseurl ="http://api.cs-networks.net:9011/bin/send";

stream data = wc.Openread(baseurl);
treamReader reader = new StreamReader (data);

string s = reader.ReadToEnd ();

data.Close ();

reader.Close ();

return (s);




Note : You can use WebClient.UploadString() method too ....


Article by srirama
A Good advice from parent to a Child , Master to a Student , Scholar to an Ignorant is like a doctor prescribed pill it is bitter to take but when they take it will do all good for them --- Bhushan

Follow srirama or read 73 articles authored by srirama

Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: