Automating quote delivery to your Gmail

Shubham Gupta
3 min readAug 29, 2021

Everyone loves a good quote. However we forget our own favourite quotes. So I built a simple script in Google Sheets to send me a quote every morning from the list of quotes that I had compiled.

At the onset, I would like to say that this will be helpful for anyone just getting started or getting their feet wet in writing simple scripts to automate tasks and make life easier for them.

The idea originated from being able to see my “own” favourite quotes more often. There are a lot of apps around there but they usually throw quotes from off the internet but which won’t resonate with me. So I wanted to build something which would show me my own favourite quotes from time to time.

And if you are not convinced about the power of quotes, you may read about Lincoln who is said to have many a quote at his tips to be used during speeches and general conversations.

However if you are okay with quotes which are not your own and gives you great pictures, then do try the Momentum chrome extension https://chrome.google.com/webstore/detail/momentum/laookkfknpbbblfpciffpaejjkokdgca?hl=en. It will show you awesome pictures from around the world with a quote below.

now once you have decided thsi, i went about deciding this how did I want my quote delivered to me. That was the tricky part. My initial thought was along the lines of sending the quote as a notification on my phone. Like I would wake up everyday and see a notification on my lockscreen. However that was beyond the scope of my capabilities and also a bit ephemeral. With so many notifications, I could just pass this with a swipe. So I went for something easier. That of automating quote delivery to my inbox using Scripts of Google Sheets.

The steps are:

  1. I exported all my data from my Google docs to Google Sheets to have a sheet which would list down all my favourite quotes. This is how it looks like below:

2. Then using Tools-> Script editor I wrote a script to send me automatic emails every day between 8am and 9am.

P.S. While doing all this, I also realised the innumerable use case of Google Sheets and how useful it can be. However, that can be a separate topic for itself but I would highly recommend checking that out and you might possibly find a good shortcut for your workflow.

3. My code that I have written in the script editor is simple; basically at each trigger it picks up a random quote and sends it to my email in the format that I desire it.

Here is the code:

function myFunction() {

var ss = SpreadsheetApp.getActiveSpreadsheet()

var sheet1=ss.getSheetByName(‘Sheet1’);

var max= sheet1.getRange(2,10).getValue();

var row= Math.floor(Math.random()*(max-2))+2;

var emailAddress = sheet1.getRange(row,1).getValue();

var subject = sheet1.getRange(row,2).getValue();

var message = sheet1.getRange(row,3).getValue();

var message_full= sheet1.getRange(row,4).getValue() + “\n” + message + “ — “ + sheet1.getRange(row,5).getValue();// this basically is the format in which I want my quote to be presented to me.

MailApp.sendEmail(emailAddress, subject, message_full, {name: ‘Your daily Quote’});

}

There is a lot of other cool stuff that you can do with Google Sheets. I hope this provides a starting point and provides some level of confidence with you having automated something by yourself. Yayy !

Would love to hear how you have modified my version to fit your needs. Please do comment below with all your knowledge. I realise that there might be a better way of doing this and I would love to hear suggestions on the same.

Thanks

I am not one to write usually but me writing this post is a way of saying thanks to the innumerable medium posts which I would have gone to build this little thing. Hopefully, this will help someone just starting out with trying to build something ‘cool’ for themselves and make them

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response