Click here to Skip to main content
15,897,291 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
C#
public void SendpasswordSMS(string mobileno, string number, string username)
    {
        int x = 0;
        mobileno = "91" + mobileno;
        string msg = "Dear " + username + ", PASSWORD is:" + number + ";
        // SMS GATEWAY PROVIDER PATH 
// here i use my gateway.
//string url = "http://.........";

        string url1 = String.Format(url, mobileno);
        ///create Web Request object for the url
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url1);
        // get the response from the web request
        HttpWebResponse res = (HttpWebResponse)req.GetResponse();
        // read the response from the WebResponse in to a stram 
        Stream s = res.GetResponseStream();
        StreamReader rdr = new StreamReader(s);
        string result = rdr.ReadLine();
        x++;
        s.Flush();
        s.Close();
    }

This code is working fine when I am using it with desktop application but it didn't work with ASP.NET application.

Earlier this was working fine.
What and where is the problem?

Please help me.
Posted
Updated 1-Aug-10 1:39am
v2
Comments
Sandeep Mewara 1-Aug-10 7:41am    
What is the issue? Error? Any configuration change from before?
sachees123 2-Aug-10 0:47am    
Issue is IM NOT BEEN ABLE SEND SMS VIA THIS CODE
narendrarathod 2-Aug-10 3:06am    
what about int x ?
you try to debug it or
try write one script and then for sms send success
Dalek Dave 6-Aug-10 6:37am    
Reason for my vote of 5
Well presented question.
thatraja 7-Aug-10 3:22am    
Yes, DD is right

Try this code .
string ProxyServer = null;
string ProxyUser = null;
string ProxyPass = null;
string ProxyPort = null;
ProxyServer = "00.00.00.00";
ProxyUser = "abc";
ProxyPass = "xyz";
ProxyPort = "8080";
string url = "http://.........";
WebRequest req = WebRequest.Create(url);
// Get Website Proxy
req.Proxy = WebProxy.GetDefaultProxy();
//req.Proxy = new WebProxy(ProxyServer + ":" + ProxyPort, true);
//req.Proxy.Credentials = new NetworkCredential(ProxyUser, ProxyPass);
req.Proxy.Credentials = CredentialCache.DefaultCredentials;
//req.Proxy.Credentials = new NetworkCredential(ProxyUser, ProxyPass); 
WebResponse resp = req.GetResponse();
// Stream the data
System.IO.StreamReader textReader = new System.IO.StreamReader(resp.GetResponseStream());


More Info : www.Book4dotnet.com
 
Share this answer
 
v5
Comments
Dalek Dave 6-Aug-10 6:36am    
Edited for Code Block.
There may be some issue regarding SPAM message filter. You need to talk to your provider. They will be able to help you in this regard.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900