Saturday, 18 February 2017


Send Text Message Using Asp.net C#


Hi,I am Navid Shaikh today i am going to show you how to send Text Message using asp.net C#

 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.

in this article I am using Bulksms service to send text message,

In order to use this API you need to
1. Register at Site2SMS and get Username and Password.
2. Register at www.mysmsmantra.com  and generate key. 

he following HTML markup consists of TextBoxes for entering Recipient mobile number, message to be sent as SMS and a Button.




<body>

    <form id="form1" runat="server">
        <table>
            <tr>
                <td>Mobile No :</td>
                <td>
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>Text Message :</td>
                <td>
                    <asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine" Rows="3"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:Button ID="btnsend" OnClick="btnsend_Click" runat="server" Text="Send" />
                </td>
            </tr>


        </table>
    </form>
</body>



Include Following Assemblies on aspx.cs page:

using System.Net;
using System.IO;
using System.Net.Mail;



aspx.cs code type in button click event:


HttpWebRequest myReq =(HttpWebRequest)WebRequest.Create("Type your key and mobile no and text message ");
            HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
            System.IO.StreamReader respStreamReader = new                  System.IO.StreamReader(myResp.GetResponseStream());
            string responseString = respStreamReader.ReadToEnd();
            respStreamReader.Close();

            myResp.Close();





output:

No comments:

Post a Comment