You must Sign In to post a response.
  • Category: ASP.NET

    Send to send sms using asp.net

    hi dns,

    can someone help how to send sms using .net.
    i tried with the old webservices available but it did't get me a proper answer.
  • #625872
    Hi,

    if you want to use SMS Message Option in your web application,

    OZEKI NG SMS Gateway is giving free gateway for send sms from your system to mobile network.


    To build an SMS solution, you need to find a way to connect your system to the mobile network. Ozeki NG SMS Gateway Several connection methods

    Try Below Links,

    ozekisms.com/index.php?owpn=230
    ozekisms.com/index.php?ow_page_number=230

    I hope it will help you.

    Thanks

    Suresh.S

    "IF YOU WANT TO SHINE LIKE A SUN FIRST YOU HAVE BURN LIKE IT".

  • #625935
    Here is a sample code, you may opt some another Web service that provide the facility to send the SMS.


    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;

    namespace SmsTest
    {
    ///

    /// Summary description for WebForm1.
    ///

    public class WebForm1 : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.Button Send;
    protected System.Web.UI.WebControls.TextBox txtMobileNo;
    protected System.Web.UI.WebControls.TextBox txtEmailId;
    protected System.Web.UI.WebControls.TextBox txtCountryCode;
    protected System.Web.UI.WebControls.Label lblMessage;
    protected System.Web.UI.WebControls.RadioButtonList rdoType;
    protected System.Web.UI.WebControls.TextBox txtMessage;

    private void Page_Load(object sender, System.EventArgs e)
    {
    txtCountryCode.Enabled = false;
    }

    #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: This call is required by the ASP.NET Web Form Designer.
    //
    InitializeComponent();
    base.OnInit(e);
    }

    ///

    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    ///

    private void InitializeComponent()
    {
    this.Send.Click += new System.EventHandler(this.Send_Click);
    this.rdoType.SelectedIndexChanged += new System.EventHandler(this.rdoType_SelectedIndexChanged);
    this.Load += new System.EventHandler(this.Page_Load);

    }
    #endregion

    private void Send_Click(object sender, System.EventArgs e)
    {
    if (txtEmailId.Text.Trim() == "")
    {
    lblMessage.Visible = true;
    lblMessage.Text = "Please Enter Email ID";
    txtEmailId.Focus();
    return;
    }
    else if (txtMobileNo.Text.Trim() == "")
    {
    lblMessage.Visible = true;
    lblMessage.Text = "Please Enter Mobile No";
    txtMobileNo.Focus();
    return;
    }
    else if (txtMessage.Text.Trim() == "")
    {
    lblMessage.Visible = true;
    lblMessage.Text = "Please Enter Message";
    txtMessage.Focus();
    return;
    }
    else
    {
    try
    {
    SmsTest.net.webservicex.www.SendSMS smsIndia = new SmsTest.net.webservicex.www.SendSMS();
    SmsTest.com.webservicex.www.SendSMSWorld smsWorld = new SmsTest.com.webservicex.www.SendSMSWorld();
    if (rdoType.SelectedValue == "1")
    smsIndia.SendSMSToIndia(txtMobileNo.Text.Trim(), txtEmailId.Text.Trim(), txtMessage.Text);
    else
    smsWorld.sendSMS(txtEmailId.Text.Trim(), txtCountryCode.Text.Trim(), txtMobileNo.Text.Trim(), txtMessage.Text);
    lblMessage.Visible = true;
    lblMessage.Text = "Message Send Succesfully";
    }
    catch (Exception ex)
    {
    lblMessage.Visible = true;
    lblMessage.Text = "Error in Sending message" + ex.ToString();
    }
    }
    }

    private void rdoType_SelectedIndexChanged(object sender, System.EventArgs e)
    {
    if(rdoType.SelectedValue =="1")
    txtCountryCode.Enabled = false;
    else
    txtCountryCode.Enabled = false;

    }

    protected void Clear_Click(object sender, EventArgs e)
    {
    txtEmailId.Text = "";
    txtCountryCode.Text = "";
    txtMobileNo.Text = "";
    txtMessage.Text = "";
    lblMessage.Visible = false;
    txtEmailId.Focus();
    }
    }
    }


    And here is the .aspx page code.

    <%@ Page Language="c#" CodeBehind="SendSms.aspx.cs" AutoEventWireup="false" Inherits="SmsTest.WebForm1" %>

    <html>
    <head>
    <title>Sending Text Messages with .NETtitle>
    head>
    <body>
    <table width="100%" border="1px">
    <tr>
    <td align="center">
    <h2>
    Send SMSh2>
    td>
    tr>
    <tr>
    <td align="center">
    <asp:Label ID="lblMessage" runat="server" ForeColor="#009900" Visible="False">asp:Label>
    td>
    tr>
    table>
    <form method="post" runat="server" id="Form1">
    <table width="100%" border="1px">
    <tr>
    <td colspan="2" height="22">
     
    <asp:RadioButtonList ID="rdoType" runat="server" AutoPostBack="True" RepeatDirection="Horizontal"
    Width="304px">
    <asp:ListItem Value="1" Selected="True">SMS to Indiaasp:ListItem>
    <asp:ListItem Value="2">SMS to worldasp:ListItem>
    asp:RadioButtonList>
    td>
    tr>
    <tr>
    <td>
    Email Id
    td>
    <td>
    <asp:TextBox ID="txtEmailId" runat="server">asp:TextBox>( ex : test@test.com
    )
    td>
    tr>
    <tr>
    <td>
    Country Code
    td>
    <td>
    <asp:TextBox ID="txtCountryCode" runat="server" Text="">asp:TextBox> (ex
    : 91 for India
    td>
    tr>
    <tr>
    <td>
    Mobile/cell Number
    td>
    <td>
    <asp:TextBox ID="txtMobileNo" runat="server" Text="">asp:TextBox> ( ex : 984xxxxxxxx )
    td>
    tr>
    <tr>
    <td>
    Message
    td>
    <td>
    <asp:TextBox ID="txtMessage" runat="server" Rows="4" TextMode="MultiLine">asp:TextBox>
    td>
    tr>
    <tr>
    <td>
    td>
    <td>
    <asp:Button ID="Send" runat="server" Text="Send">asp:Button>
    <asp:Button ID="Clear" runat="server" Text="Clear" OnClick="Clear_Click">asp:Button>
    td>
    tr>
    table>
    form>
    body>
    html>

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM


This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.