Can I email multiple recipients through GmailApp.sendEmail()? I've tried storing the recipient addresses as an array, but it doesn't seem to send any of them.
Thanks!
Yes you can.
If you direct yourself towards the Google Apps Spreadsheet services, you can see under the Gmail method that there are advanced parameters. GmailApp Services
It can look something like this.
GmailApp.sendEmail(recipient, subject, message, {cc: "[email protected],[email protected]"});
I never liked that way, and if I was sending to a varying number of people, and wanted to send them each an email instead of it being one big CC, the work around I found was this:
var emails = ["[email protected]","[email protected]","[email protected]"];
for (var i = 0; i < emails.length; i++) {
GmailApp.sendEmail(emails[i], subject, message);
}
This way you can just simply edit the emails array by adding/subtracting an email and never having to change the actual code that sends the email. Only downside is it sends out X number of emails based on how many addresses you have in the array (if you're worried about hitting the daily cap), but it works none the less.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With