suresh s

suresh s

  • NA
  • 37
  • 175.5k

Sending SMS using Asp.Net with C#

Sep 10 2008 10:46 AM

I have encountered a problem in sending SMS from my .net web application. I have used the below code for sending the SMS,

private String readCustomerComp(string url)
    {
        String result = "";
        String strPost = "";
        StreamWriter myWriter = null;
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);          

        objRequest.Method = "POST";
       
        try
        {
            myWriter = new StreamWriter(objRequest.GetRequestStream());           
            myWriter.Write(strPost);
        }
        catch (Exception e)
        {
            return e.Message;
        }
        finally
        {
            myWriter.Close();
        }

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
        {
            result = sr.ReadToEnd();
            // Close and clean up the StreamReader
            sr.Close();
        }
        return result;
    }


I get the following error from my server - "Remote server returned an error - (401) Unauthorised

What does this error means?

Is there any other way to send SMS from .net application?

Help


Answers (1)