In this tutorial i am going to share with you How to Send Bulk SMS in Asp.Net C#. Or Also Explain How to Use SMS Gateway to Send BulkSMS in Asp.Net.
You can Send Bulk SMS in Asp.Net with using SMS Gatway. Many Website are provide free SMS Gateway such as Way2sms, Site2SMS, FullOnSMS, Ultoo.com, Freesms8,Sms440, BhokaliSMS, IndyaRocks.com, 160by2 and etc.
To Send Successfully SMS You need to Follow this Steps:
Step 1: SignUp or Register at Site2SMS and Get Username and Password.
Step 2: SignUp or Register at www.mashape.com and Generate API Key.
Step 3: Download the .DLL file ASPSnippets.SmsAPI.dll from ASPSnippets.com and add it in your project >> bin folder. Click here to Download
Step 5: Enjoy
HTML Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Send SMS </title> <style type="text/css"> .auto-style1 { height: 60px; color: #FFFFFF; } body { font-family: Arial; font-size: 10pt; } .auto-style2 { height: 26px; color: #FF9900; } </style> </head> <body> <form id="form1" runat="server"> <div> <table border="0"> <tr> <td class="auto-style1" colspan="3" style="text-align: center; background-color: #FF9900"><strong>Send Bulk SMS in Asp.Net</strong></td> </tr> <tr> <td>Your Mobile Number: </td> <td> <asp:TextBox ID="txt_MobileNumber" placeholder="Mobile Number" runat="server" Width="181px"></asp:TextBox> </td> <td> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Required" ControlToValidate="txt_MobileNumber" ForeColor="Red"></asp:RequiredFieldValidator> </td> </tr> <tr> <td>Your Site2Sms Password: </td> <td> <asp:TextBox ID="txt_Password" placeholder="Password" TextMode="Password" runat="server" Width="181px"></asp:TextBox> </td> <td> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Required" ControlToValidate="txt_Password" ForeColor="Red"></asp:RequiredFieldValidator> </td> </tr> <tr> <td>Reciever mobile Number: </td> <td> <asp:TextBox ID="txt_RecieverNumber" placeholder="Reciever Number" runat="server" Width="181px"></asp:TextBox> </td> <td> <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Required" ControlToValidate="txt_RecieverNumber" ForeColor="Red"></asp:RequiredFieldValidator> </td> </tr> <tr> <td>Message Boby Text: </td> <td> <asp:TextBox ID="txt_BodyMessage" runat="server" placeholder="Message" TextMode="MultiLine" Width="181px"></asp:TextBox> </td> <td> <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="Required" ControlToValidate="txt_BodyMessage" ForeColor="Red"> </asp:RequiredFieldValidator> </td> </tr> <tr> <td></td> <td> <asp:Button ID="btn_Sendsms" runat="server" Text="Send SMS" BackColor="#009900" BorderStyle="None" ForeColor="White" Height="33px" Width="97px" OnClick="btn_Sendsms_Click" /> </td> <td></td> </tr> <tr> <td colspan="3"> <center> <asp:Label ID="Label1" Font-Bold="true" ForeColor="Green" runat="server"></asp:Label> </center> </td> </tr> <tr> <td class="auto-style2" colspan="3" style="text-align: center; background-color: #000000">Copyright © www.asppoint.com</td> </tr> </table> </div> </form> </body> </html>
C# Code:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.IO; using ASPSnippets.SmsAPI; using System.Text; using System.Net; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btn_Sendsms_Click(object sender, EventArgs e) { SMS.APIType = SMSGateway.Site2SMS; SMS.MashapeKey = "<Mashape API Key>"; SMS.Username = txt_MobileNumber.Text.Trim(); SMS.Password = txt_Password.Text.Trim(); if (txt_RecieverNumber.Text.Trim().IndexOf(",") == -1) { //Single SMS SMS.SendSms(txt_RecieverNumber.Text.Trim(), txt_BodyMessage.Text.Trim()); Label1.Text="Your SMS Sent Successfully...!"; } else { //Multiple SMS List<string> numbers = txt_RecieverNumber.Text.Trim().Split(',').ToList(); SMS.SendSms(numbers, txt_BodyMessage.Text.Trim()); Label1.Text="Your SMS Sent Successfully...!"; } } }
If you have any kind of question about any post, Feel free to ask.You can simply drop a comment below post. Your feedback and suggestions will be highly appreciated. ConversionConversion EmoticonEmoticon