Pages

SENDING SMS VIA WAY2SMS IN ASP.NET C#

Saturday, May 28, 2011


Here is the code for sending sms via way2sms in asp.net c#. It is one way api, that is we can only send sms, no receiving facility is provided. For using this code first you should create a account in way2sms with a valid Indian mobile phone number. Then you get username and password. Use the code as you like.

#####################################################################################
 public void send(string uid, string password, string message, string no)
{
HttpWebRequest myReq =
(HttpWebRequest)WebRequest.Create("http://ubaid.tk/sms/sms.aspx?uid=" + uid + "&pwd=" + password +
"&msg=" + message + "&phone=" + no + "&provider=way2sms");

HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
string responseString = respStreamReader.ReadToEnd();
respStreamReader.Close();
myResp.Close();
}


(2)- On The aspx page take two textboxes and a button and on the click event of the button call the function like--

protected void Button1_Click(object sender, EventArgs e)
{
send("yourmobileno","yourpassword", TextBox2.Text, TextBox1.Text);
}

//only change yourmobileno and
//yourpassword below
//TextBox2.Text for message and
//TextBox1.Text for reciever no


(3)- Dont forget to use namespaces
using System.Net;
using System.IO;

//************Hope it helps************//


#####################################################################################

29 comments:

manu said...

Nice works da

BUZONE said...

it really works...after seeing a lot of article of found urs and its simple 2 understand also..thnx...

Ravinder said...

it is working great ....

Vidhya said...

thank u so much... :)

programming knowledge said...

હા તે સાચે જ કામ કરે છે.

Gourav said...

Thank you very much....Its very helpfull...Hats of to you....

RAHUL303 said...

Thank u dear friend,,,,,,,,

P N V Srinivas said...

g8 thanks its working bro

Unknown said...

Thanx dude.. really it's very nicely working..

Unknown said...

in How much Time I get message??

.net for you said...

HI man, if more than 5 sms are sent with same account, the sms's are not available.


System.Net.WebException was unhandled
Message=The operation has timed out
Source=System
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at WindowsFormsApplication1.Form1.send(String uid, String password, String message, String no) in E:\VS SAMPLES\samplepractise\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs:line 27
at WindowsFormsApplication1.Form1.button1_Click(Object sender, EventArgs e) in E:\VS SAMPLES\samplepractise\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs:line 42
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WindowsFormsApplication1.Program.Main() in E:\VS SAMPLES\samplepractise\WindowsFormsApplication1\WindowsFormsApplication1\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Mohamed Ubaidullah said...

Dharwish, thanks for your article. I'm honoured.

Thanks,
Ubaid

Navzzy said...

http://tecntricks.blogspot.in/2012/03/way2sms-desktop-application.html

Navzzy said...

Here iS Way2sms desktop application

Upendra Bittu said...

hey i got this


Error 1 'System.Net.HttpWebRequest' does not contain a definition for 'GetResponse' and no extension method 'GetResponse' accepting a first argument of type 'System.Net.HttpWebRequest' could be found (are you missing a using directive or an assembly reference?)

Upendra Bittu said...

i got that error when i used it to develop it for windows phone app using visual studio 2010. please mail me the solution to upendra1991@gmail.com

Navzzy said...

Have You Tried This Site
neway4u

Unknown said...

Ubaid my friend, you are AWESOME!

pradeep said...
This comment has been removed by a blog administrator.
TechSolution for you said...
This comment has been removed by the author.
Krishna Thota said...

Is this API working right now??I'm sorry if I hurt you coz. I made a App using another API similar to this previously and it is not working now. I think way2sms guys have changed the API.

Help said...

Thank you,
I am sending message US it is possible?
Pls give example on send SMS to US (or) world,

If any free time check my below requirement like this,
I am redirect home url to coupouns url send sms to seller,

For example redirect to coupouns page url send sms with coupn page url using asp.net....

Thank you,
anil

Guruprasad Bhavsar said...

hye thanx for solution..
but this is nt wrking at my place.
m gting error "The remote server returned an error: (503) Server Unavailable."

wht should i do??

thanx in adv...

Unknown said...

sir,
HttpWebRequest myReq =
(HttpWebRequest)WebRequest.Create("http://ubaid.tk/sms/sms.aspx?uid=" + uid + "&pwd=" + password +
"&msg=" + message + "&phone=" + no + "&provider=way2sms");

ubaid.tk is not working .. can u have another way to send sms code pls reply mail me . mail id : david89222@gmail.com

anjali said...

thanku sir ! it really works


Er. Abhishek said...


HttpWebRequest myReq =
(HttpWebRequest)WebRequest.Create("http://ubaid.tk/sms/sms.aspx?uid=" + uid + "&pwd=" + password +"&msg=" + message + "&phone=" + no + "&provider=way2sms");

Earlier this code was working , but now this is not working. Please help me.

hsinspiration said...

HttpWebRequest myReq =
(HttpWebRequest)WebRequest.Create("http://ubaid.tk/sms/sms.aspx?uid=" + uid + "&pwd=" + password +"&msg=" + message + "&phone=" + no + "&provider=way2sms");

Earlier this code was working , but now this is not working. Appreciate any help with this

Unknown said...

can u have another way to send sms code t send sms using c# ASP.NET,.
pls mail me the new code.
mail id : kprabha6@gmail.com

InfoCepts said...

www.probuztech.com

http://asp-net-concept.blogspot.in/2013/05/how-to-send-sms-to-mobile-number-which.html

 

Most Reading