I am trying to write a script to send an email to a distribution list housed in a google spreadsheet. I am using a test sheet with only 3 email addresses on the list before I move this into a live environment. I'd like it to send to me, and bcc everyone on the list. The script works fine if I put the list of email addresses in the recipient spot of sendEmail, but not when I try to move the email addresses to the bcc spot using the bcc advanced argument of sendEmail. In that case I get the following error:
Error encountered: Invalid email: [L;@130cab11
In this error the "130cab11" portion changes everytime I run the script. The only consistent part of the script is "Error encountered: Invalid email: [L; ..."
The relevant portion of my script is below:
// Retrieve data for the Email that will be sent///
var email_column = ss.getSheetByName(sendtosheet)
var lastrow = email_column.getLastRow()
var get_email_data = email_column.getRange(2,2,lastrow-1,1).getValues()
var emailTemplate = ss.getSheetByName("Email Templates").getRange("B1").getValue()
var aliases = GmailApp.getAliases();
Logger.log(aliases)
//Format the email
var advancedArgs = {bcc:get_email_data,from: aliases[0]}
var Self = "[email protected]"
var subject = "INVITE: Upcoming Focus Group Session";
var message = emailTemplate
//Send the email
GmailApp.sendEmail(Self, subject, message, advancedArgs)
This code works without error if I send the email without using the bcc argument and have the sendEmail code structured like this:
//Send the email
GmailApp.sendEmail(get_email_data, subject, message, {from: aliases[0]})
I have searched stackoverflow and google scripts manuals and everywhere else I can think of so any help would be appreciated.