In this article I will explain how to send Free SMS and Free Bulk SMS to mobile (cell) numbers in ASP.Net website. There are many websites that allow sending free SMS to mobile (cell) numbers like Way2sms, FullOnSMS, 160by2, Site2SMS, IndyaRocks.com SMSAbc.com, Ultoo.com, SmsSpark.com SMSFI.com Freesms8, Sms440, BhokaliSMS, etc.
The above sites allow users to send Free SMS to any Mobile or Cell Number.
Thus to make it easier for the .Net Community I have introduced an API for sending SMS using Site2SMS which uses the online API from Mashape.com.
In order to use this API you need to
1. Register at Site2SMS and get Username and Password.
2. Register at Mashape.com and generate key.
 
 
Generate Key at Mashape.com
You need to refer the following URL to get the details.
How to register to Mashape and get API key to send SMS using Site2SMS in ASP.Net
 
 
 
HTML Markup
The following HTML markup consists of TextBoxes for entering Username, Password, Recipient mobile number, message to be sent as SMS and a Button.
<form id="form1" runat="server">
<table border="0">
<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_Click" />
    </td>
    <td>
    </td>
</tr>
</table>
 
Note:  The ASPSnippets.SmsAPI.dll is available in the attached sample code as well as can be downloaded by clicking here.
 
Namespaces
You will need to import the following Namespace after adding reference of ASPSnippets.SmsAPI.dll file
C#
using ASPSnippets.SmsAPI;
 
VB.Net
Imports ASPSnippets.SmsAPI
 
 
ASPSnippets SMS API Usage
The following code snippet describes the Button click event handler. In order to use the SMS API you need to first set the API Type, specify the Mashape Key and the Username and Password for the SMS Service provider here it will be Site2SMS.
Then there’s a check to look for comma (,) in the Recipient Mobile number. You can either add a single number or multiple numbers separated by comma in the TextBox.
C#
protected void btnSend_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 (txtRecipientNumber.Text.Trim().IndexOf(",") == -1)
    {
        //Single SMS
        SMS.SendSms(txtRecipientNumber.Text.Trim(), txtMessage.Text.Trim());
    }
    else
    {
        //Multiple SMS
        List<string> numbers = txtRecipientNumber.Text.Trim().Split(',').ToList();
        SMS.SendSms(numbers, txtMessage.Text.Trim());
    }
}
 
VB.Net
Protected Sub btnSend_Click(sender As Object, e As EventArgs)
    SMS.APIType = SMSGateway.Site2SMS
    SMS.MashapeKey = "<Mashape API Key>"
    SMS.Username = txtNumber.Text.Trim()
    SMS.Password = txtPassword.Text.Trim()
    If txtRecipientNumber.Text.Trim().IndexOf(",") = -1 Then
        'Single SMS
        SMS.SendSms(txtRecipientNumber.Text.Trim(), txtMessage.Text.Trim())
    Else
        'Multiple SMS
        Dim numbers As List(Of String) = txtRecipientNumber.Text.Trim().Split(","c).ToList()
        SMS.SendSms(numbers, txtMessage.Text.Trim())
    End If
End Sub
 
 
Demo
 
Downloads