Resources » Code Snippets » ASP.NET WebForms

Send SMS using ASP.Net


Posted Date: 11-Nov-2009  Last Updated:   Category: ASP.NET WebForms    
Author: Member Level: Gold    Points: 10



A small Code Which Sends SMS from your ASP.Net Application

For it to work the Application you will need -
1) Account in Way2sms.com
2) Fill the FromNumber, FromPassword before starting to send sms


private void SendSMS(string ToNumber, string Message)
{
SendSms.SendSMS objSms = null;
try
{
objSms = new SendSms.SendSMS();
objSms.AllowAutoRedirect = false;
if (!(objSms.sendSMSToMany(FromNumber, FromPassword, txtTo.Text, txtMessage.Text).Contains("done")))
{
lblError.Text = "some error in port. Please try after some time";
lblError.Visible = true;
}
else
{
lblError.Text = "Message sent successfully";
lblError.Visible = true;
}
}
catch (Exception)
{
throw;
}
finally
{
if (objSms != null) objSms = null;
}
}



In the above code 'SendSms.SendSMS' is a web service where you need to add web reference to your project

To Add that to your project solution explorer right click->Add Web Reference
type the url or copy paste the below url


http://www.aswinanand.com/sendsms.php?wsdl


And in Right Side Corner you find the Web Reference Name there give 'SendSms' or what ever you want

Hope that will help some one


Did you like this resource? Share it with your friends and show your love!

Responses to "Send SMS using ASP.Net "
Author: Mohammad Vahaj uddin    13 Nov 2009Member Level: Silver   Points : 0
Is it gonna work from out side the India?


Author: Praveen    13 Nov 2009Member Level: Gold   Points : 2
hi,

it according to the account you have created in way2sms.com

if you register account from any other country you have to give your account number and account password

and in way2sms.com even you can login with email but in my code you have to login with phone number that you have registered!!!!!



Author: karthik    29 Mar 2010Member Level: Bronze   Points : 1
Hi,
I am developing windows application and i need to send sms from my application. I have used your code and it is giving "Error in port".What is the problem i am facing please guide me.



Guest Author: rinku     10 Dec 2012
i have an account on way2sms. i want to send sms from asp.net C# language website.


Author: Praveen    29 Jan 2013Member Level: Gold   Points : 2
Hi rinku,

The service reference is not working.

http://www.c-sharpcorner.com/UploadFile/b8d90a/send-sms-using-C-Sharp-net/


the above link has example. Download smsclient.dll which they provided link and see the example code.

Hope that will help you

Regards,
Praveen



Guest Author: visweswararao     13 Feb 2014
it shows error when adding the web reference


Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Subscribe to Subscribers
    Awards & Gifts
    Talk to Webmaster Tony John

    Online Members

    Gopi A
    More...
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India