MailApp.sendEmail suddenly stopped working in Google Sheets
Hey All,
I'm a teacher who has to keep track of what students take lunches. I have a spreadsheet that as I check students off who take lunches, it builds a message for the following days lunch order. At the end of lunch, every day this school year, I've run the script below that has then sent an email with the message from the spreadsheet to the nutrition services folks.
Unfortunately, a few days ago, the script suddenly stopped working. It now throws up an exception and tells me the parameters don't match the method signature. I have changed nothing within the code. The only change between it working, and not working, was I duplicated a tab, which I have done every Friday this school year.
I can understand basic code. I'm not quite sure what exactly is wrong suddenly. I've tried to dive into the Google hole to solve the issue and have come up short. I've recreated the code in a new function, as well as tried a simple, boiled down version, in a new Sheets. All give me the same error.
Here is the code:
function newSendEmail() {
var emailRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("New Text Scripts").getRange("F8");
var emailAddress = emailRange.getValues();
var getMessage = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("New Text Scripts").getRange("B10");
var message = getMessage.getValues();
var getDate1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("New Text Scripts").getRange("B6");
var date1 = getDate1.getValues();
var getDate2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("New Text Scripts").getRange("C6");
var date2 = getDate2.getValues();
var getDate3 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("New Text Scripts").getRange("D6");
var date3 = getDate3.getValues();
var subject = 'XXXXXXXX School Lunch Order for ' + date1 + ', ' + date2 + ' ' + date3;
MailApp.sendEmail(emailAddress, subject, message, {
cc: '[email protected]'
});
}
I'm unsure of the best way to format it for this post so your eyeballs don't want to bleed. Apologies if I did it wrong.
Any suggestions/fixes??
Posted Feb 27, 2020, 4:20 AM UTC