Send SMS on Registration



In this post how to send SMS on Registration.

using System.Net;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Specialized;

-----------------------------------------


User Defined Method
-----------------------------------------

public void savedata()
    {
        String query = "insert into registrationdetail(uname,emailaddress,contactno) values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text +  "')";
        String mycon = "Data Source=sk-pc; Initial Catalog=ContestDatabase; Integrated Security=true";
        SqlConnection con = new SqlConnection(mycon);
        con.Open();
        SqlCommand cmd = new SqlCommand();
        cmd.CommandText = query;
        cmd.Connection = con;
        cmd.ExecuteNonQuery();
        Label3.Text = "You Have Successfully Registered For Contest - Thank You";
       
        
    }


-----------------------------------------

Register Button Click Event Coding
-----------------------------------------

        string destinationaddr = "91" + TextBox3.Text;
        string message = "Hi " + TextBox1.Text + " , You Have Been Registered For The Contest. Thanks!!";

        String message1 = HttpUtility.UrlEncode(message);
        using (var wb = new WebClient())
        {
            byte[] response = wb.UploadValues("https://api.textlocal.in/send/", new NameValueCollection()
                {
                {"apikey" , "FammnpFW0Ks-gRKkiQvnke2nG940NkDbbl4jUV4elK"},
                {"numbers" , destinationaddr},
                {"message" , message1},
                {"sender" , "TXTLCL"}
                });
            string result = System.Text.Encoding.UTF8.GetString(response);
            savedata();
            Label3.Text = "You Have Successfully Registered";

------------------------------------------

0 Comment's

Comment Form

Submit Comment