You must Sign In to post a response.

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.


Comments

Author: Suresh08 Aug 2011 Member Level: Gold   Points : 1

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

Author: Anil Kumar Pandey08 Aug 2011 Member Level: Diamond   Points : 3

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" %>



Sending Text Messages with .NETtitle> <BR>head> <BR><body> <BR><table width="100%" border="1px"> <BR><tr> <BR><td align="center"> <BR><h2> <BR>Send SMSh2> <BR>td> <BR>tr> <BR><tr> <BR><td align="center"> <BR><asp:Label ID="lblMessage" runat="server" ForeColor="#009900" Visible="False">asp:Label> <BR>td> <BR>tr> <BR>table> <BR><form method="post" runat="server" id="Form1"> <BR><table width="100%" border="1px"> <BR><tr> <BR><td colspan="2" height="22"> <BR>  <BR><asp:RadioButtonList ID="rdoType" runat="server" AutoPostBack="True" RepeatDirection="Horizontal" <BR>Width="304px"> <BR><asp:ListItem Value="1" Selected="True">SMS to Indiaasp:ListItem> <BR><asp:ListItem Value="2">SMS to worldasp:ListItem> <BR>asp:RadioButtonList> <BR>td> <BR>tr> <BR><tr> <BR><td> <BR>Email Id <BR>td> <BR><td> <BR><asp:TextBox ID="txtEmailId" runat="server">asp:TextBox>( ex : test@test.com <BR>) <BR>td> <BR>tr> <BR><tr> <BR><td> <BR>Country Code <BR>td> <BR><td> <BR><asp:TextBox ID="txtCountryCode" runat="server" Text="">asp:TextBox> (ex <BR>: 91 for India <BR>td> <BR>tr> <BR><tr> <BR><td> <BR>Mobile/cell Number <BR>td> <BR><td> <BR><asp:TextBox ID="txtMobileNo" runat="server" Text="">asp:TextBox> ( ex : 984xxxxxxxx ) <BR>td> <BR>tr> <BR><tr> <BR><td> <BR>Message <BR>td> <BR><td> <BR><asp:TextBox ID="txtMessage" runat="server" Rows="4" TextMode="MultiLine">asp:TextBox> <BR>td> <BR>tr> <BR><tr> <BR><td> <BR>td> <BR><td> <BR><asp:Button ID="Send" runat="server" Text="Send">asp:Button> <BR><asp:Button ID="Clear" runat="server" Text="Clear" OnClick="Clear_Click">asp:Button> <BR>td> <BR>tr> <BR>table> <BR>form> <BR>body> <BR>html><BR></pre></code></FONT></p></div></div></div></div></div> <div class="row"> <div class="col-md-12"> <div class="item"> <form method="post" action="./ViewForumDetails.aspx?ForumId=292822" id="Form1" class="form-horizontal"> <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMjA3ODQ3MjU2MmRkSJ/Yxy6C9APSBWiEi2kO5cJyxwZg238aYUhpqVWqidI=" /> <input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="BC243B5E" /> <input type="submit" name="ctl00$ContentPlaceHolder1$btnSubscribe" value="Subscribe" id="ContentPlaceHolder1_btnSubscribe" disabled="disabled" class="aspNetDisabled" onclick="return ConfirmSubscription('1');" /> <input type="submit" name="ctl00$ContentPlaceHolder1$btnUnSubscribe" value="Un Subscribe" id="ContentPlaceHolder1_btnUnSubscribe" disabled="disabled" class="aspNetDisabled" onclick="return ConfirmSubscription('0');" /> <br /> <a name="PostReply"></a> <span id="ContentPlaceHolder1_lblResponseMessage"><b></b></span> </form> </div> </div> </div> </div> <div class="row"> <div class="col-md-6"> <a href='PostForum.aspx'>Submit New Thread</a> </div> <div class="col-md-6"> Return to <a href="index.aspx">Return to Discussion Forum</a> </div> </div> </div> <div class="col-md-4 sidebar"> <div class="row"><div class="item"><div data-type="ad" data-publisher="lqm.dotnetspider2.site" data-format="300x250" data-zone="ros" data-tags="microsoft.net%2csql%20server%2cprogramming%2cc#%2cvb.net%2casp.net%2ccloud%20computing%2csoftware%20development"></div> </div></div><div class="row"><div class="item"><a href="http://emarketing.lakequincy.com/public/phWC/tW7/subscribe" target="_blank" rel="nofollow"><img border="0" alt="Subscribe to Subscribers" src="http://emarketing.lakequincy.com/images/integration/buttons/green.gif" /></a></div></div><div class="row"><div class="item"><b><font face='Arial' color='black'>Top Contributors</font></b><BR><I style='line-height:150%'><B>Today</B></I><ul class='activeList'><LI class='compact'><a href='/member/DivyaHR.aspx'>Sunsmart Techno...</a> (4)</li><LI class='compact'><a href='/member/KD001.aspx'>Kedar</a> (3)</li></ul><I><B>Last 7 Days</B></I><ul class='activeList'><LI class='compact'><a href='/member/koolprasad2003.aspx'>Prasad kulkarn...</a> (74)</li><LI class='compact'><a href='/member/snaveen.aspx'> naveensanagase...</a> (45)</li><LI class='compact'><a href='/member/kumaraspcode.aspx'>Dotnet Develop...</a> (40)</li></ul><a href='/members/TopPerformers.aspx'><font size=1>more...</font></a><br /><br /></div></div><div class="row"><div class="item"><script language="javascript" type="text/javascript"> <!-- src = ["/images/general/cash.jpg", "/pictures/profiles/thumbs/koolprasad2003__Mic.jpg", "/pictures/profiles/thumbs/shashikantgurav__shashi.jpg", "/pictures/profiles/thumbs/snathanm__snathanm__Nathan.jpg", "/pictures/profiles/thumbs/pawansoftit__34617168.jpg", "/pictures/profiles/thumbs/pawansoftit__34617168.jpg", "/pictures/profiles/thumbs/snathanm__snathanm__Nathan.jpg", "/pictures/profiles/thumbs/koolprasad2003__Mic.jpg", "/pictures/profiles/thumbs/shashikantgurav__shashi.jpg", "/pictures/profiles/thumbs/koolprasad2003__Mic.jpg", "/pictures/profiles/thumbs/pawansoftit__34617168.jpg"] url = ["/credits/", "/credits/", "/credits/", "/credits/", "/credits/", "/credits/", "/credits/", "/credits/", "/credits/", "/credits/", "/credits/"] //set duration for each image duration = 3; ads=[]; ct=0; function switchAd() { var n=(ct+1)%src.length; if (ads[n] && (ads[n].complete || ads[n].complete==null)) { document["Ad_Image"].src = ads[ct=n].src; } ads[n=(ct+1)%src.length] = new Image; ads[n].src = src[n]; setTimeout("switchAd()",duration*1000); } function doLink() { location.href = url[ct]; } onload = function() { if (document.images) switchAd(); } //--> </script> <b style='color:#000000'>Awards & Gifts</b><table height=110><tr><td align=center><a href="javascript:doLink();" onMouseOver="status=url[ct];return true;" onMouseOut="status=''"><img name="Ad_Image" src="/images/general/cash.jpg" border="0"></a></td></tr></table></div></div><div class="row"><div class="item"><h3>Email subscription</h3><small><li><a href='http://feedburner.google.com/fb/a/mailverify?uri=dotnetspider/jobs' target="_blank" rel="nofollow">.NET Jobs</a></li><li><a href='http://feedburner.google.com/fb/a/mailverify?uri=dotnetspider/articles' target="_blank" rel="nofollow">.NET Articles</a></li><li><a href='http://feedburner.google.com/fb/a/mailverify?uri=dotnetspider/forums' target="_blank" rel="nofollow">.NET Forums</a></li> <img src='/images/general/rss.jpg'> <a href='http://www.dotnetspider.com/resourcesrss.xml' target=_blank>Articles Rss Feeds</a> <br><img src='/images/general/rss.jpg'> <a href='http://www.dotnetspider.com/forumrss.xml' target=_blank>Forum Rss Feeds</a></small></div></div><div class="row"><div class="item"><iframe src="http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2FDotNetSpider%3Fcreated&width=300&colorscheme=light&show_faces=true&border_color&stream=false&header=false&height=302" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:300px; height:302px;" allowTransparency="true" marginwidth=0 margingheight=0></iframe></div></div><div class="row"><div class="item"><h3>Online Members</h3><a href="/member/Ulaga.aspx">Boopa</a><br><a href='/general/OnlineMembers.aspx'><small>More...</small></a></div></div> </div> </div> </div> <div class="container-fluid footer"> <div class="row bottom-bar"> <div class="col-md-12 text-center"> <a class="btn-bottom-bar" href="/general/AboutUs.aspx">About Us</a> <a class="btn-bottom-bar" href="/general/ContactUs.aspx">Contact Us</a> <a class="btn-bottom-bar" href="/general/Copyrights.aspx">Copyright</a> <a class="btn-bottom-bar" href="/general/PrivacyPolicy.aspx">Privacy Policy</a> <a class="btn-bottom-bar" href="/general/TermsOfUse.aspx">Terms Of Use</a> <a class="btn-bottom-bar" href="/pages/Advertise.aspx" rel="nofollow">Advertise</a> </div> </div> <div class="row copyright"><div class="col-md-12 text-center">Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India</div></div> </div> <script type='text/javascript'> function _dmBootstrap(file) { var _dma = document.createElement('script'); _dma.type = 'text/javascript'; _dma.async = true; _dma.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + file; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(_dma); } function _dmFollowup(file) { if (typeof DMAds === 'undefined') _dmBootstrap('cdn2.DeveloperMedia.com/a.min.js'); } (function () { _dmBootstrap('cdn1.DeveloperMedia.com/a.min.js'); setTimeout(_dmFollowup, 2000); })(); </script> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-4428394-1', 'auto'); ga('send', 'pageview'); </script> <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <script src="/script.min.js"></script> <div id="fb-root"></div> <script> (function (d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3&appId=211956038847988"; fjs.parentNode.insertBefore(js, fjs); } (document, 'script', 'facebook-jssdk'));</script> </body> </html>