I have been looking around the forums and I've been unable to find a solution to this, I'm trying to email multiple sheets as separate attachments in the same email, so far I'm able to email as attachment only one, but can't seem to find the way to select multiple sheets to add to the attachments, below my code:
function sendTimelist() {
var emailRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Configure").getRange("B2");
var email = emailRange.getValues();
var emailAddress = email;
var mailReplyTo = email;
var subject = 'Weekly Email Alerts';
var message = '\bHi team\b,\n\nPlease find the Data of Sheets.\n\nThank you,\.';
var attachmentName = 'Test.csv';
var fileId = "Ac12154d4s5dsd87s8d";
var timelist = UrlFetchApp.fetch(
"https://docs.google.com/feeds/download/spreadsheets/Export?key=" + fileId + "&exportFormat=csv",
{
"headers": {Authorization: "Bearer " + ScriptApp.getOAuthToken()},
"muteHttpExceptions": true
}
).getBlob().setName(attachmentName);
var optAdvancedArgs = {replyTo: mailReplyTo, name: attachmentName, attachments: [timelist] };
GmailApp.sendEmail(emailAddress, subject, message, optAdvancedArgs);
}
Any ideas? Thanks.