In this tutorial I will explain you how to use Twilio to send SMS using C# and ASP.NET. You can send SMS to any phone number and anywhere in the world. Let us first introduce you to Twilio.
Twilio allows making and receiving phone calls and also sending and receiving text messages, using its APIs. Programmers can implement Twilio APIs in their code and create all sort of applications involving phone calls and SMS. It’s services are accessed over HTTP and are billed based on usage. It can be used easily in our application for creating features like SMS authentication, OTP, SMS marketing and more.
I have also written a similar tutorial for sending SMS using PLIVO. You should also check that tutorial after you have read this one.
In this tutorial I will create a simple code which will send SMS to a mobile number using Twilio API.
protected void Page_Load(object sender, EventArgs e)
{
string AccountSid = "Your Twilio Account Sid";
string AuthToken = "Your Twilio Auth Token";
var twilio = new TwilioRestClient(AccountSid, AuthToken);
var message = twilio.SendMessage("+13343164589", "+919818924213", "Jenna please?! I love you", "");
}
Note that in the above twilio.SendMessage() function has 3 parameters –
a) First Parameter – the twilio phone numbers which you can get from the twilio API. The cost of this number starts from $1 per month.
b) Second Parameter – the number to which you have to send the SMS.
c) Third Parameter – the SMS message
For using helper libraries in other languages like php, perl, C++, phython, Java etc visit – https://www.twilio.com/docs/libraries
Download Codes: