Introduction:
In my previous article I explained SMS Gateways and the various schemes available for them. This article explains how to integrate those SMS gateways into an ASP.Net web application.
What a "SMS Gateway" is
A SMS Gateway allows a computer to send or receive SMS to or from a telecommunications network. This Wikipedia URL provides more detail.
Some “facts” about SMS Gateways
When I did some experimentation and Googling of SMS gateways some of the tutorials suggested use of “free” SMS gateways. But nothing worked for me. Latter I understood that “Nothing comes free”. Also most people asked the same question: “Is there any free SMS service is available to send SMS from my website?”. In my experience the answer is no. So my point here is, don’t waste your time searching for the free API. Instead, find a well-suited SMS Gateway provider and sign up with them.
What next
Well you want to send a SMS from your ASP.Net web application. So as a first step, you need to sign up with a SMS Gateway provider to get the SMS credits. Normally all SMS gateway providers provide at least 10 free SMS credits to check their services. Also they will provide details of the Application Programming Interfaces (APIs) and explain in detail how to integrate those API codes into your application.
For demo purposes I have signed up an account with mvaayoo SMS gateway providers and will use their services in this tutorial.
Markup
For the simple illustrative purposes, I’m going to develop a simple UI in a web-form as in the following. I have a textbox to accept mobile numbers and a button to send the message. That’s all!
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title></title>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <asp:Label runat="server" Text="Enter Mobile Number"></asp:Label>
- <asp:TextBox runat="server"></asp:TextBox>
- <br />
- <asp:Button runat="server" ID="btnSent" Text="Sent SMS" OnClick="btnSent_Click"></asp:Button>
- </div>
- </form>
- </body>
- </html>
Code behind
In the code behind file, we need to copy and paste the API code provided by the SMS Gateway. As I already explained, every SMS Gateway service provider provides the API code to be used in your application. In mvaayoo, they provide the API code for ASP.Net, ASP, VB and PHP too. You need to substitute the user name password and sender id in the respective places in the URL. You need to also specify the mobile number too in the URL. If you want to send the SMS to multiple numbers then you need to provide those numbers in comma-separated format.
- protected void btnSent_Click(object sender, EventArgs e)
- {
- // use the API URL here
- string strUrl = "http://api.mVaayoo.com/mvaayooapi/MessageCompose?user=YourUserName:YourPassword&senderID=YourSenderID& receipientno=1234567890&msgtxt=This is a test from mVaayoo API&state=4";
- // Create a request object
- WebRequest request = HttpWebRequest.Create(strUrl);
- // Get the response back
- HttpWebResponse response = (HttpWebResponse)request.GetResponse();
- Stream s = (Stream)response.GetResponseStream();
- StreamReader readStream = new StreamReader(s);
- string dataString = readStream.ReadToEnd();
- response.Close();
- s.Close();
- readStream.Close();
- }
That’s all! You have successfully created an application to send SMS messages.

Manoj ChouksePosted Aug 2, 2020, 2:06 AM
How to send sms on mobile number above .aspx and c# code is not in working. Textbox are not link from Code behind then how can do send sms and what message will be send?
Fahid AliPosted May 4, 2020, 12:43 AM
Sir how to send sms in Pakistan . when i careate account its validate mobile number text box ( Number should begin with 91) please tell me the solution.
Shiva XeroxPosted Sep 5, 2019, 10:15 AM
Bypass otp vbnet server website
Asif KhanPosted May 30, 2019, 2:50 PM
How to send bulk sms
Sriyashree SwainPosted Aug 5, 2018, 12:09 PM
When i click on the link, it says Status=1, API Time Expired
Vijay GuptaPosted Feb 1, 2018, 11:54 AM
This code is not working. But run properly
KarthikPosted Aug 12, 2017, 4:50 AM
Go to that below link register and then get API Code....
KarthikPosted Aug 12, 2017, 4:48 AM
Http://www.mvaayoo.com/UI/Api.aspx
KarthikPosted Aug 12, 2017, 4:47 AM
Hi Dude...Thnx for your code explanation......i searched many websites for sending sms...nothing was worked for me....but its your code is 100% working...Thnq.....Thnx mvaayoo........
yaphethPosted Apr 16, 2017, 10:51 PM
How to send sms in asp.net using c# http://keranservices.blogspot.com/2014/01/how-to-send-sms-in-aspnet-using-c.html
Ananya VadapallyPosted Mar 15, 2017, 5:38 AM
Hey Francis, great article I agree that nothing comes free I have also searched for a lot of free SMS providers but couldn't find any. Now I am using www.textlocal.in SMS platform which has helped me in scaling up my business they have their API available for free which is very easy to use.
Mahammmad ShakeefPosted Nov 8, 2016, 12:32 AM
Hi,i tired a s you said above,but sms did not send
Mahammmad ShakeefPosted Nov 8, 2016, 12:31 AM
Hi,I tried as you explained above.
kalu singh raoPosted Jul 18, 2016, 3:31 AM
Nice...
vetriselvan vetriPosted Jun 8, 2016, 10:54 AM
I got this Error"Cannot read from a closed TextReader."
Samiksha SinghPosted Oct 26, 2015, 8:17 AM
actually i have registered to http sms api gateway so what type of sms account is this?how would i registerd with transactional account in mvaayoo?do i need to pay for it?
Samiksha SinghPosted Oct 26, 2015, 8:02 AM
i have tried both above option but its not working.i think i am having free credentilas account in mvaayoo,
Samiksha SinghPosted Oct 26, 2015, 8:00 AM
Ttp://api.mVaayoo.com/mvaayooapi/MessageCompose?user=YourUserName:YourPassword&senderID=YourSenderID& receipientno="+txtContact.Text+"&msgtxt=This is a test from mVaayoo API&state=4
Samiksha SinghPosted Oct 26, 2015, 8:00 AM
ttp://api.mVaayoo.com/mvaayooapi/MessageCompose?user=YourUserName:YourPassword&senderID=YourSenderID& receipientno=txtContact.Text&msgtxt=This is a test from mVaayoo API&state=4
Samiksha SinghPosted Oct 26, 2015, 7:48 AM
how can i change the receipient no. dynamically
Samiksha SinghPosted Oct 26, 2015, 7:44 AM
message is not recived by other recipient
Samiksha SinghPosted Oct 26, 2015, 7:43 AM
i have alrady done that ...
Samiksha SinghPosted Oct 26, 2015, 6:05 AM
how can i change the receipent no. from "http://api.mVaayoo.com/mvaayooapi/MessageCompose?user=YourUserName:YourPassword&senderID=YourSenderID& receipientno=1234567890&msgtxt=This is a test from mVaayoo API&state=4"
Punam RaundalPosted Aug 13, 2015, 8:55 AM
code not working..it cant send msg to the no which enter in text box
Gaurav GuptaPosted May 26, 2015, 6:14 AM
code is not working....help me please
Francis SusaimichaelPosted May 7, 2015, 8:07 AM
Thank you :)
Santhakumar MunuswamyPosted Apr 24, 2015, 3:24 AM
Good