Tags

, ,


Send SMS from ASP.Net
To Send SMS we Need following params:
1. URL=http://provider :: provided by Service Provider
2. userId=abc ::provided by Service Provider
3. pass=abcx ::provided by Service Provider
4. appid=BSNL::Register Company Name with Serice Provider
5. contenttype=text/htm :: Set Content Type
6. selfid=true
7. to= 919298877698 ::on which SMS will send (919298877698)
8. from=BSNL ::Register Company Name with Serice Provider
9. dlrreq=true
10. alert=1
11. text=SMS Text :: SMS Text in HTML or Text Format
params can be vary according to provider

On Button Click Event write the Following code

//Step 1:: Store the URL
string URL = “http://push1.maccesssmspush.com/servlet/com.aclwireless.pushconnectivity.listeners.TextListener”;

//Step 2:: Create the Request format
string mStrWebRequest =”{0}?userId={1}&pass={2}&appid={3}&contenttype={4}&selfid=true&to={5}&from={6}&dlrreq=true&alert=1&text={7}”;

//Step 3:: Place Paramaters values in WebRequest
mStrWebRequest = string.Format(mStrWebRequest, URL, UserName, Password, ApplicationName, ContentType,
mStrPhoneNo, From, smsBody);

//Step 4:: Create a Web Request
HttpWebRequest mobjRequest = (HttpWebRequest)WebRequest.Create(mStrWebRequest);

//Step 5:: Get Response from Provider Server
HttpWebResponse mobjResponse = (HttpWebResponse)mobjRequest.GetResponse();

//Step 6:: Get Stream from Response
StreamReader mobjStreamReader = new StreamReader(mobjResponse.GetResponseStream());

//Step 7:: Read the response Message from Stream
string mstrSMSResponse = mobjStreamReader.ReadLine();

Now show message according to Response.
Note:: If Company Name Return in Response that mean message has been sent.

Enjoy!

Advertisements