Sending SMS through ASP.NET using SMS sending API from providers

Hi, Here i am describing you simplest way to send SMS using ASP.NET and API from SMS sender providers.

Whenever you will get SMS's from providers they will give you userid , password and senderid also they will provide you API to integrate with your website to send sms.

If you have any control panel from providers then you will get API from support or SMS Integration section.

To integrate this API you need to use add System.IO and System.Net namespaces.

Below is the demo code:

protected void btnSendMessage_Click(object sender, EventArgs e)
    {
        string senderusername = "xxxxx";
        string senderpassword = "xxxx";
        string senderid = "xxx";       
        string sURL;
        StreamReader objReader;
        sURL = "http://thundersms.com/smsapps/pushsms.php?username=" + senderusername + "&password=" + senderpassword + "&sender=" + senderid + "&mobile=91" + txtMobileNumber.Text + "&type=1&message=" + txtMessage.Text;
        WebRequest wrGETURL;
        wrGETURL = WebRequest.Create(sURL);
        try
        {
            Stream objStream;
            objStream = wrGETURL.GetResponse().GetResponseStream();
            objReader = new StreamReader(objStream);
            objReader.Close();
        }
        catch (Exception ex)
        {
            ex.ToString();
        }
    }

Note: Please note that your send URL may be different than above. Here i am using thundersms.com API.

Below Demo Code Available for Download.

SMS_Demo.rar (1.67 kb)


No Comments

Add a Comment