Wednesday, June 30, 2010

To send sms through http port

We can send sms through a dedicatd http port to mobile no. To implement that, we need a very small code in c#.net. And we can use that code on the basis of the requirement of the server.
----------------------
String httpAddress = "http://192.164.4.224:8237/cpSubscriptionService/Default.aspx?key=ppl_450w98";
String mobileNo = txtMobile.Text;
String sentMessage = txtMessage.Text;
String out_Msg_Id = txtOutMsg_id.Text;
String sendRequest = httpAddress+ "&mobileNo="+mobileNo+"&body="+sentMessage+"&msg_type=4&send_port=003225&in_Msg_Id=1&out_Msg_Id="+out_Msg_Id;

HttpWebRequest loHttp = (HttpWebRequest)WebRequest.Create(sendRequest);

//loHttp.Timeout = 10000;
loHttp.Method = "GET";

HttpWebResponse loWebResponse = (HttpWebResponse)loHttp.GetResponse();

Encoding enc = Encoding.GetEncoding(1252); // Windows default Code Page
StreamReader loResponseStream = new StreamReader(loWebResponse.GetResponseStream(), enc);

string lcHtml = loResponseStream.ReadToEnd();
txtResponse.Text = lcHtml;

loWebResponse.Close();
loResponseStream.Close();
---------------------------------

For that purpose, we have just used the http port for the example purpose. Here three text box has been used just to take the no., text and the feedback field. Here in the program these fields have been used.

No comments: