Saturday, 15 June 2013

send sms in asp.net c#



-----------------------------------------------------------------
using System.Web.Services;
using System.Net;




public void sendsms()
    {
        try
        {
            string smsMessage = "Welcome In AEEI" + "\r";
            smsMessage += txt_msg.Text.Trim();
            string MobileNo = txt_mobileno.Text.Trim();

            WebClient client = new WebClient();

            if (MobileNo != "")
            {
                string baseurl = "http://sms.softhunters.in/pushsms.php?username=India Ltd.&password=293908&sender=Avyukta&to=" + MobileNo + "&message=" + smsMessage + "";
                //string baseurl = "http://sms.creativeinfovision.in/pushsms.php?username=Creativeinfovision&password=your_password&sender=9829606976&to=9461816878&message=Hello";
           
                Stream data = client.OpenRead(baseurl);
                StreamReader reader = new StreamReader(data);
                string s = reader.ReadToEnd();
                data.Close();
                reader.Close();
            }
        }
        catch (Exception ex)
        {

        }

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

protected void Page_Load(object sender, EventArgs e)
    {
        string smsMessage = "Dear Customer Congratulations!!!," + "\r";
        smsMessage += "call on 91-98-220-12345  or mail @ ccare.mh@idea.adityabirla.com visit @ http://www.ideacellular.com " + "\r";
     
       


        //string MobileNo = txt_telephone.Text.Trim();
        HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        WebClient client = new WebClient();
        string no = "9887901185";

        if (no != "")
        {
         
            string baseurl = "http://sms.softhunters.in/pushsms.php?username=SSMTPL&password=529670&sender=SSMTPL&to=" + no + "&message=" + smsMessage + "";
            Stream data = client.OpenRead(baseurl);
            StreamReader reader = new StreamReader(data);
            string s = reader.ReadToEnd();
            data.Close();
            reader.Close();
        }
    }


-----------------------------------------
ON  logic.Registration_Entry Time---->
-------------------------------------------
sendsms();


public void sendsms()
    {
        string smsMessage = "Welcome In PinkCity Gold Trading(P.)Ltd." + "\r";
        smsMessage += "Your-UserID:" + usernewId + "\r";
        smsMessage += "Your-SponsorID:" + sponsorid + "\r";
        smsMessage += "Your-Password:" +Session["pwd"].ToString();


        string MobileNo = txt_telephone.Text.Trim();
        //HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        WebClient client = new WebClient();

        // string baseurl = " http://sms.ziindia.com/sendurl.asp?user=20008672&pwd=12345&mobileno=9828437743&msgtext=hello h r u";
        if (MobileNo != "")
        {
            string baseurl = "http://sms.softhunters.in/pushsms.php?username=Pinkcity Gold&password=264966&sender=Pinkcity&to=" + MobileNo + "&message=" + smsMessage + "";
            //string baseurl = "http://sms.creativeinfovision.in/pushsms.php?username=Creativeinfovision&password=your_password&sender=9829606976&to=9461816878&message=Hello";


            Stream data = client.OpenRead(baseurl);
            StreamReader reader = new StreamReader(data);
            string s = reader.ReadToEnd();
            data.Close();
            reader.Close();
        }
    }
--------------------------------------------------------------------

SMS Sending Code More than one Person
------------------------------------>

using connection_layer;
using TestWeb;
using System.IO;
using System.Net.Mail;
using System.Web.Services;
using System.Net;

public partial class Admin_Sukh_SMS_Gateway : System.Web.UI.Page
{
    cls_connection con = new cls_connection();
    DataSet ds = new DataSet();
    DataSet dsddl = new DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                dsddl = con.select_data_ds("SELECT MainID, Telephone FROM EndUserAddress");
                ddl_UseID.DataSource = dsddl;
                ddl_UseID.DataTextField = "MainID";
                ddl_UseID.DataValueField = "Telephone";
                ddl_UseID.DataBind();
            }
            catch (Exception ex)
            {

            }
            mul.ActiveViewIndex = 0;
        }
    }
    protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (RadioButtonList1.SelectedValue == "0")
        {
            mul.ActiveViewIndex = 1;
        }
        else
            mul.ActiveViewIndex = 2;
    }
    protected void btn_send_2all_Click(object sender, EventArgs e)
    {
        try
        {
            ds = con.select_data_ds("SELECT Telephone FROM EndUserAddress");
        }
        catch (Exception ex)
        {
        }

        HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        WebClient client = new WebClient();
        string smsMessage = txt_usermessage.Text;
        for (int i = 0; i <ds.Tables[0].Rows.Count; i++)
        {
            string MobileNo = ds.Tables[0].Rows[i][0].ToString();
            if (MobileNo != "")
            {
                string baseurl = "http://sms.softhunters.in/pushsms.php?username=SSMTPL&password=529670&sender=SSMTPL&to=" + MobileNo + "&message=" + smsMessage + "";
                Stream data = client.OpenRead(baseurl);
                StreamReader reader = new StreamReader(data);
                string s = reader.ReadToEnd();
                data.Close();
                reader.Close();
            }
        }
        string prompt = "<script>$(document).ready(function(){{$.prompt('{0}!');}});</script>";
        string message = string.Format(prompt, "Message Has been Sent to the All Users. ");
        ClientScript.RegisterStartupScript(typeof(Page), "message", message);

    }
    protected void btn_back_Click(object sender, EventArgs e)
    {
        mul.ActiveViewIndex = 0;
    }
    protected void btn_send_Click(object sender, EventArgs e)
    {
        try
        {
            HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            WebClient client = new WebClient();
            string smsMessage = txt_send.Text;
            string MobileNo = ddl_UseID.SelectedValue.ToString();
            if (MobileNo != "")
            {
                string baseurl = "http://sms.softhunters.in/pushsms.php?username=SSMTPL&password=529670&sender=SSMTPL&to=" + MobileNo + "&message=" + smsMessage + "";
                Stream data = client.OpenRead(baseurl);
                StreamReader reader = new StreamReader(data);
                string s = reader.ReadToEnd();
                data.Close();
                reader.Close();
                string prompt = "<script>$(document).ready(function(){{$.prompt('{0}!');}});</script>";
                string message = string.Format(prompt, "Message Has been Sent to the User. ");
                ClientScript.RegisterStartupScript(typeof(Page), "message", message);
            }
        }
        catch (Exception ex)
        {
        }
    }
}
----------------------------------------------------------------------------

No comments:

Post a Comment