Thursday, November 3, 2011
Package Arrival Email Automation, google apps script
The packages for MITERS makerships are being routed through me (to force people to go to MITERS, heh). I wrote a quick and dirty script to automate notifying people by email when the packages arrive at MITERS. My first try at google apps scripting.
Google's documentation is excellent: http://code.google.com/googleapps/appsscript/service_spreadsheet.html
The code is like so:
Which corresponds to a spreadsheet is set up like so.
So, the full steps:
You start out with the raw spreadsheet. Then, to add a script to it, got to Tools > Script Editor... which will take you to a blank version of the following. To check your script for errors, you hit the play button here.
Now, go to Tools > Script Manager > Run to run your script and create the custom menu (which is just for convenience for running your script, but invaluable when you're rerunning all the time to debug). The first time Google will double-check with you if you want to run this script, since it's doing Dangerous Things like emailing people under your name. After that you're set.
The emails, interestingly enough, will NOT thread/group in gmail. So this is still a rather spamtastic script. _shrug_ I don't care enough. You can see my testing emails below:
I didn't choose to use an HTML template for me email. See http://googleappsdeveloper.blogspot.com/2011/10/4-ways-to-do-mail-merge-using-google.html if you want to implement that.