Thursday, 13 June 2013

SMS using

Introduction- Hello "Developers"!! How are you friends? Through this article, i will show how , we can send Sms by  using any gatway url. This article will very helpful for all the .net developers to send sms..

Implementation- create a website , add page named negative_chart.aspx. place a literal control at the design side of this page. Below I am giving the complete code for .aspx page and also .aspx.cs page.

Code for SendSms.aspx Page-

<head runat="server">
    <form id="form1" runat="server">
    <asp:Button ID="btn_snd_sms" runat="server" Text="Send Sms"
            onclick="btn_snd_sms_Click" />

Code for SendSms.aspx.cs Page-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class sms : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)

    // Here i am creatind a string function to send the sms.
    public string SendSms(string mobile_number, string message)

        { // i am taking a string to cath the complete url
            string baseurl = null;
            // here i am using the dummy url, this url will not working.
            // Whwn you will buy sms from any sms gatway then they will provide any url. on that url you will pass the two parameters
            //like as mobile number and you message which you want to send.
          // In the below url i am passing two parameters first one is mobile number and second one is message.
            baseurl = "" + mobile_number + "&uname=FACEBOOK&passwd=batala852&cli=FACEBOOK&message=" + message;
            // System.Net.WebClient  Provides common methods for sending data to and receiving data from a resource identified by a URI.
            System.Net.WebClient client = new System.Net.WebClient();
            //IOstreams can be used for a wide variety of data manipulations
            // in System.IO.Stream data i am passing the complete url with mobile number and message
            System.IO.Stream data = client.OpenRead(baseurl);
            //The StreamReader class is designed for character input in a particular Encoding, whereas subclasses of Stream are designed for byte input and output.
            System.IO.StreamReader reader = new System.IO.StreamReader(data);
            // When complete sms will be sent to mentioned number then a successfully message will come in the string s variable
            string s = reader.ReadToEnd();
            return s;
        catch (Exception ex)
            // if there will be any error then that error will come inside this exception.
            throw ex;



    protected void btn_snd_sms_Click(object sender, EventArgs e)
        // in the number string variable i am passing mobile number and in the message_client variable i am passing the message.
        string number,message_client;
        number = "9646073316";
        message_client = "";
        // Here i am calling the method and passing the parameters
        SendSms(number, message_client);

Conclusion- Through this article, you have learned how we can send SMS by using any url or any gatway in If you have any idea to improve this article, please send  on my mail id, I will try to improve my next article.



  1. Try to provide whole code in zip file.

    1. Hello Aadii, You can copy the code and paste it in your Application. And you must need for real URL. You need to buy SMS gatway. After buying they will provide you a url. On that url you will pass your own parameters by using this code.

  2. hi mail me the procedure to buy sms gateway

  3. Unable connect remote server..please help me

  4. Hi pasupathi,

    Have you buy any SMS gatway service? If yes then can you provide me the URL of your service via email, if no then you need to buy SMS gatway service to resolve this error..


  5. This comment has been removed by the author.