Google Apps Script. Wait…what?
A few months earlier, I discovered Google Apps Script and decided to play with it. Google Apps Script allows you to interact with many Google products (Gmail, Documents, Finance, Maps, Calendar) by writing some code for these apps. The amazing point is that the documentation for Google Apps Script is just awesome. I’ll write it again because it really is: it’s awesome. The documentation is really well written and the Google team provide useful (and so much powerful!) functions. And last but not least, it’s beautiful. Amazing.
An example with Gmail
Once again, a few months ago, I saw on Twitter that a guy was complaining about his Gmail Inbox. This guy received a lot of emails everyday (he said more than 300 if I remember well) and hadn’t enough time to read them all. So he asked on Twitter, “Is there a way to tell people that I just want to read short emails?” and someone gave him just a little script to do so. This script used Google Apps Script and especially the GmailApp class. You can read the documentation of this class here: developers.google.com/apps-script/reference/gmail/gmail-app.
I was excited about that: the code was really beautiful, simple and powerful. So I decided to rewrite it by myself, just to try writing my very first Google Apps Script. Enough talk, here is the code!
Okay, seems cool. How to use it?
Well, my goal was just to show how awesome Google Apps Script could be. I don’t think that you want to use this script for your personal use (unless you’re a very popular person!). But if you still want to use it for you, just go to script.google.com, create a new file, copy and paste the code and try executing it. Google will ask your approval before you’ll be able to interact with Gmail thanks to this code (thanks Google for this security).
Test it, and once you’ll like the way it works, run periodically this code (e.g. every 5 minutes) with a timer by selecting “Resources” > “Current project’s triggers…” in Google Script. Your Inbox will always be super clean 😉
Ressources
Your bible, the documentation for Google Apps Script: developers.google.com/apps-script/.
One thought on “Using Google Apps Script: an example with Gmail”
Comments are closed.