forum has moved from a google groups forum to a Google+ community.If you are a regular here, you may have noticed that our
I had never noticed before, but there is a groups service in Apps Script that allows you to access things about that group, including the members. Using this allowed me to send a note to all forum members about this change. Here's how
This is real straightforward. Assuming you are an administrator of the group, all you need is the email address of the group, and this function will give you an array of email addresses of everyone in the group. Note also that i'm only taking a chunk of emails at a time. This is because the MailApp service has a quota of people to whom it can email each day, so I'm running this over a period of a few days.
I wanted to send a customized email to each one, so once the message has been formatted, sending them is just this
I can use Html Service to render a formatted email from a template. I didn't bother with formal templating for this trivial task - I'm simply going to push each email address into a DOM element to personalize.
Here's my template index.html
It's worth a few words on google.script.run(). I need to orchestrate 2 of these, and they run asynchronously. In a normal app I would have used ES6 Promises along with a shim for older browsers, but caja doesn't like them, and I didn't want to bring in jQuery just for that, so you'll see that runGooglyThingy() takes an optional additional argument of what to run next. This is pretty simple way of orchestrating asynchronous tasks if you don't have Promises available.
That's all. If you got one of these emails, that's how you got it. If you didn't why not head over to the desktop liberation google plus community and join up.
For more on this topic, see Running things in parallel using HTML service. For more snippets like this see Google Apps Scripts snippets
For help and more information join our forum,follow the blog or follow me on twitter .
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Google Apps Script HTML service >