Sending SMS with PLIVO in ASP.NET and C#

Sending SMS with PLIVO in ASP.NET and C#

In websites we see the feature of sending SMS to customer’s mobile no. This is done for a no of reasons like sending one time password (OTP), authentication, marketing and more. You can also add SMS sending feature in your website very easily using PLIVO ( which is a Global SMS & Voice calls service.


In this tutorial we will teach you how to send SMS using Plivo SMS API in your ASP.NET website. First create your account in Plivo website and generate AUTH ID and AUTH TOKEN. With these auto id and auth token you can communicate with Plivo API to send SMS to the desired mobile no.

Now in your ASP.NET website ‘Bin’ folder include two .dll files a) Plivo.dll b) RestSharp.dll . With these .dll files we can easily communicate with Plivo API using REST. To download these .dll files click here.

Adding Plivo.dll to Bin FolderAdding Plivo.dll to Bin Folde>

Adding Plivo.dll to Bin Folder

We have listed the code for sending SMS. Include the following namespace in your web page.

using RestSharp;
using Plivo.API;
using System.Collections.Generic;

Code for Sending SMS using Plivo API –

public partial class test : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        if (!IsPostBack)
      	    bool result = SendSms("+919123451234", "+919871552204", "Send SMS using Plivo");  
    public bool SendSms(string from, string to, string text)
        string authId=”Your Plivo autoId”;
        string autoToken=”Your Plivo autoToken”;
        RestAPI plivo = new RestAPI(authId, autoToken);
        IRestResponse resp = plivo.send_message(new Dictionary<string, string>() 
                { "src", ""+from+"" }, // Sender's phone number with country code
                { "dst", ""+to+"" }, // Receiver's phone number wiht country code
                { "text", ""+text+"" }, // Your SMS text message
                // To send Unicode text
                // {"text", "こんにちは、元気ですか?"} // Your SMS text message - Japanese
                // {"text", "Ce est texte généré aléatoirement"} // Your SMS text message - French
                { "url", ""}, // The URL to which with the status of the message is sent
                { "method", "POST"} // Method to invoke the url
        return true;

The good thing using Plivo is that with it you can send Global SMS too in very cheap price. All new users get $2 free trial amount for sending SMS. Use it to do testing of your application without spending SMS money.

To download it- DOWNLOAD

Share this article -



This article has been written by the Technical Staff of YogiHosting. Check out other articles on "WordPress, SEO, jQuery, HTML" and more.