Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to send SMS via Asp.Net Application

    • 0
    • 1
    • 0
    • 0
    • 3
    • 0
    • 0
    • 0
    • 2.19k
    Comment on it

    "Send SMS via Asp.Net Application"

        In this article I will explain how to send Free single/bulk SMS through Asp.Net Application.

       There are many websites that allow sending free messages such as Way2sms, FullOnSMS, 160by2, Site2SMS, IndyaRocks.com SMSAbc.com, Ultoo.com, SmsSpark.com SMSFI.com Freesms8, Sms440, BhokaliSMS, etc.

       I will explain it with the help of Site2SMS which uses the online API from Mashape.com.

    Getting Started:

    Step 1: You have to first register yourself on Site2SMS from where you will get the UserName &
                     Password.

    Step2: Now register at Mashape.com, you have to create a sample application at Mashape.com
                    for which you will get an API key. For help go to following link,

    How-to-generate-Mashape-API-Key

    Step 3: Now as you have the API key, lets create the application, write the following HTML to create the Form:

    <table>
    <tr>
        <td>
            Your Number:
        </td>
        <td>
            <asp:TextBox ID="txtNumber" runat="server"></asp:TextBox>
        </td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
    
    ErrorMessage="Required"
                ControlToValidate="txtNumber" ForeColor="Red"></asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td>
            Password:
        </td>
        <td>
            <asp:TextBox ID="txtPassword" TextMode="Password" runat="server"></asp:TextBox>
        </td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
    
    ErrorMessage="Required"
                ControlToValidate="txtPassword" ForeColor="Red"></asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td>
            Recepient Number:
        </td>
        <td>
            <asp:TextBox ID="txtRecepientNumber" runat="server" Width = "300"></asp:TextBox>
        </td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
    
    ErrorMessage="Required"
                ControlToValidate="txtRecepientNumber" 
    
    ForeColor="Red"></asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td>
            Message:
        </td>
        <td>
            <asp:TextBox ID="txtMessage" runat="server" TextMode="MultiLine"></asp:TextBox>
        </td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
    
    ErrorMessage="Required"
                ControlToValidate="txtMessage" ForeColor="Red"></asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td>
        </td>
        <td>
            <asp:Button ID="btnSend" runat="server" Text="Send" OnClick="btnSend&#95;Click" />
        </td>
        <td>
        </td>
    </tr>
    </table>
    

       This Form will take your registered number and password at Site2Sms, Receipent Numbers and the Message to be sent.

    Step 4: Now use the Namespace after adding reference of ASPSnippets.SmsAPI.dll, you can download this dll from: `Download Link`
    NOTE->This dll contains the definition for the SMS class.

    Step 5: Now on click of the send button write the following code:

    protected void btnSend&#95;Click(object sender, EventArgs e)
    {
        SMS.APIType = SMSGateway.Site2SMS;
        SMS.MashapeKey = "<Mashape API Key>";
        SMS.Username = txtNumber.Text.Trim();
        SMS.Password = txtPassword.Text.Trim();
        if (txtRecepientNumber.Text.Trim().IndexOf(",") == -1)
        {
            //For sending single SMS
            SMS.SendSms(txtRecepientNumber.Text.Trim(), txtMessage.Text.Trim());
        }
        else
        {
            //For sending multiple SMS
            List<string> numbers = txtRecepientNumber.Text.Trim().Split(',').ToList();
            SMS.SendSms(numbers, txtMessage.Text.Trim());
        }
    }
    

    Step 6: The SMS is sent.

 3 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: