In Inviting members to Google Plus from Groups I showed how to use htmlservice to send a templated email to multiple recipients. Let’s say you want to create a spreadsheet of people you’ve sent a particular email to. Here’s how.
Regular visitors to this site will know that I’m a great fan of reusing code via libraries – no point in wasting time repeating things. We’re going to need these libraries.
Access my library to get all keys and dependencies from the majority of my public libraries

Rate limiting

The GMailApp is very strict about quotas, so I’m using exponential backoff throughout. It’s a fine balance between waiting too long between requests (waiting counts towards the 6 minute quota) and blasting too many requests for email messages.

The code

Once you have the libraries installed, there’s not much to it.

First we get all the email threads matching a query that will identify the message I want to pull out

Get the messages associated with each thread. This is the troublesome one that could blow your rate limits, so I wrap it in a backoff function.

Each message could have multiple recipients. Create an object for each one, and add to the list

Using Database abstraction with google apps script, write the results to a database – in this case it’s a spreadsheet.

Here’s the result

Here’s the whole thing

For more like this see Google Apps Scripts Snippets
For help and more information join our forum, follow the blog or follow me on Twitter