Friday, August 24, 2012

SENDING SMS VIA WAY2SMS IN ASP.NET C#

 



Here is the code for sending sms via way2sms in asp.net c#. It is one way api, that is we can only send sms, no receiving facility is provided. For using this code first you should create a account in way2sms with a valid Indian mobile phone number. Then you get username and password. Use the code as you like.
#####################################################################################
 public void send(string uid, string password, string message, string no)
{
HttpWebRequest myReq =
(HttpWebRequest)WebRequest.Create("http://ubaid.tk/sms/sms.aspx?uid=" + uid + "&pwd=" + password +
"&msg=" + message + "&phone=" + no + "&provider=way2sms");

HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
string responseString = respStreamReader.ReadToEnd();
respStreamReader.Close();
myResp.Close();
}


(2)- On The aspx page take two textboxes and a button and on the click event of the button call the function like--

protected void Button1_Click(object sender, EventArgs e)
{
send("yourmobileno","yourpassword", TextBox2.Text, TextBox1.Text);
}

//only change yourmobileno and
//yourpassword below
//TextBox2.Text for message and
//TextBox1.Text for reciever no


(3)- Dont forget to use namespaces
using System.Net;
using System.IO;

//************Hope it helps************//


###################################################################################


You might also like:

All Mobiles Secret Codes

Download youtube videos without any sofware

10 Worst Cyberattacks in 2012

Gadget Innovations of 2012