Programmatically (C#) sending reliable SMS for free using Google Calendar Event

Sending SMS is a common requirement these days for alerts, notifications, two factor authentications etc. Lot of SMS APIs and gateways are available like Twilio etc. and consuming those APIs programmatically from any programming languages is breeze but it comes with money.

For instance, Twilio costs 56 paise (.56 rupee) in INR (India Rupee) for sending 1 SMS which is lot of money if the volume is more. We found another provider Solutions Infini in Bangalore, India, they charge 20 paise (.20 rupee) INR if we buy in bulk of 25000 SMS lifetime validity for INR 5000/- . What-if if we get it for free without compromise in the reliability, response time etc. and the solution is using Google Calendar Event notification for sending out SMS.

Note: By any means this is not a complete solutions or replacement for Twilio or any other similar SMS service providers. It has its own limitations like

  1. The client or end user to whom the SMS is targeted should use Gmail [Should be okay in SME/SMB cases where the business email is Google Email]
  2. Only limited number of characters are allowed and most of it will be eaten up by the sender’s email id which is very long i.e.
  3. Doesn’t provide hooks etc.
  4. And the number goes………………

Let us jump to the implementation:

Client Pre-requisite to receive SMS alerts

5) The client or end user to whom the SMS is targeted should use Gmail

6) The client or end user should have registered their mobile phone with Google Calendar mobile setup. The procedure is available here []

Server Pre-requisite to send SMS programmatically using Google service account (un-attended UI)

1) Create a project in Google console [Screenshot -01]

2) Enable Calendar API from. Expand “APIs & Auth” in left menu and then click on APIs [Screenshot-02]

3) Click on calendar API and enable [Screenshot-03]

4) Click on credentials and create new client ID. Once done you will get the following [Screenshot-04]

  • ClientId
  • Email Address
  • Public key fingerprints
  • A key file with extension “.p12” will be downloaded. Keep this file in a safe place which we will be using while programmatically sending the SMS

Screenshot -01


Screenshot -02


Screenshot -03


Screenshot -04


Source Code

  • The C# source is self explanatory with example [embedded inside the comment] on how to invoke it from client.
  • The SMS sender is written as class file [feel free to alter and optimize as per your wish & need]
  • Important: Include the “.p12” file downloaded from the developer console in the root [change the path as per your wish]
  • VS.NET 2012 / 13 with nugget package manager 2.8.1 and above

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s