Dear Readers,In this i would like to explain how can we send an SMS
through our Application.
Now SMS sending is a most viable in most of the day today applications. Inorder to implement those kind of functionalities following code serves your purpose
SMS Sending is an Paid Service We Need to Get The Application Program Interface (API) from the Service Provider.We need to Consume that particular API from our provider. For List of API's Click Here.
public void sendSms(string Name, string MNo,string userName,string Password,string senderID)
{
try
{
string sms;
sms = "Dear " + Name + ",Thank U For Registering PNV
Technical Hub" + Environment.NewLine + "Stay tune for More Technical
Updates.For Details " + " www.seoveerendra.blogspot.in" + Environment.NewLine + "90XXXXXXXXX";
HttpWebRequest hwr = (HttpWebRequest)WebRequest.Create("http://sms.jetbulksmsservice.com/index.php/api/bulk-sms?username="+userName+"&password="+Password+"&from="+senderID+"&to=" + MNo + "&message=" + sms + "&sms_type=2");
hwr.Method = "POST";
hwr.ContentLength = 0;
hwr.ContentType = "application/x-www-form-urlencoded";
HttpWebResponse myHttpWebResponse = (HttpWebResponse)hwr.GetResponse();
myHttpWebResponse.Close();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
Explanation:
Here I will explain code
from Each and Every Parameter
1.Name : This Parameter is used to Pass the Name of
the Person in the SMS.
2.MNo : This Parameter is used to whom we need to
send an sms for this parameter we need to pass a mobilenumber
For E.G: 9010283545
3.UserName : This
parameter is used to pass the username of our SMS Account API.This can be
provided by our SMS Provider
For E.G:Pnvtech
4.Password : This
parameter is used to pass the password of our SMS Account API.This can be
provided by our SMS Provider
Note : This can be provided by SMS Provider which
will used to send an SMS
5.senderID : This
Parameter is used to Pass a SenderID in the Message.It is an 6 Characters
string which can be created by SMS Provider as per our request.
E.G:VRNDRA,JETSMS etc...
Code Explanation :
First we
need to construct a string where it depends upon our requirement.Here we need
to consume API using WebRequest.Create("")
method which is an post method passing the method type as a POST
contentlength is maximum so we can pass value as a zero.
Now you Can Integrate this code in your application and Happy Messaging.
No comments :
Post a Comment