Category >
ASP.NET
|| Published on :
Thursday, January 14, 2016 || Views:
7785
||
Sending SMS through ASPNET Sending SMS
Introduction
Here Pawan Kumar will explain how to Send SMS through ASP.NET
Description
In previous post I have explained
How to change some text before it is sent to the client in asp.net with example,
How to sum the value of gridview column using jquery in asp.net with example,
How to compress response in asp.net with example,
How to display progress indicator during ajax call in asp.net using jQuery,
How to rotating image with ASP.NET 4.0 and C# with example,
How to turn off submit button when it pressed in ASP.Net, and many more articles.
Now I will explain How to Code Snippets - Sending SMS through ASP.NET
So follow the steps to learn Code Snippets - Sending SMS through ASP.NET
Today I am describing you simplest way to send SMS using ASP.NET and API from SMS providers.
Whenever you will get SMS's from providers they will also provide you
- userid
- password
- senderid
They will provide you API to integrate with your website to send sms.
The SMS Service Provider will also provide you a control panel from providers then you will get API from support or SMS Integration section.
To integrate this API you need to use add System.IO and System.Net namespaces.
You can use the below method to Send SMS :-
protected void btnSendMessage_Click(object sender, EventArgs e)
{
string senderusername = "xxxxx";
string senderpassword = "xxxx";
string senderid = "xxx";
string sURL;
StreamReader objReader;
sURL = "http://websitename.com/smsapps/pushsms.php?username=" + senderusername + "&password=" + senderpassword + "&sender=" + senderid + "&mobile=91" + txtMobileNumber.Text + "&type=1&message=" + txtMessage.Text;
WebRequest wrGETURL;
wrGETURL = WebRequest.Create(sURL);
try
{
Stream objStream;
objStream = wrGETURL.GetResponse().GetResponseStream();
objReader = new StreamReader(objStream);
objReader.Close();
}
catch (Exception ex)
{
ex.ToString();
}
}
Please note the that in above code you have to change the websitename with your SMS Service provide URL
Hope you have enjoyed this small but useful code. Happy Coding!!!!!!
Conclusion:
So, In this tutorial we have learned, Code Snippets - Sending SMS through ASP.NET