Я пытаюсь отправить письмо с использованием сценариев Google на несколько писем, перечисленных в ячейках. Я хотел бы отправить одно электронное письмо, а другие письма были бы cc. Электронные письма перечислены в ячейках D10: D12, M5: M6 и AL10: AL12
Ссылка листа = https://docs.google.com/spreadsheets/d/1xVjEQv6FOnKk-qZgcPV4b7vdeEP3h53on2CA-jJa7iU/edit?usp=sharing
Текущий скрипт отлично работает, чтобы отправить мне письмо. Просто не могу понять, как сделать несколько электронных писем и CC.
функция sendEmail () {
var email = sheet.getRange (D10: D12) .getValues ();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var actualSheet = SpreadsheetApp.getActiveSheet ()
var sheet = ss.getActiveSheet() // Enter the name of the sheet here
var subject = "PDF from Water Polo Scoresheet - " + actualSheet.getName();
var body = "\n Attached is a PDF copy of the sheet " + sheet.getName() + " in the " + ss.getName() + " spreadsheet. For the most up to date scoresheet make sure and check www.waterpolodrills.com";
// Base URL
var url = "https://docs.google.com/spreadsheets/d/SS_ID/export?".replace("SS_ID", ss.getId());
/* Specify PDF export parameters
From: https://code.google.com/p/google-apps-script-issues/issues/detail?id=3579
*/
var url_ext = 'exportFormat=pdf&format=pdf' // export as pdf / csv / xls / xlsx
+ '&size=letter' // paper size legal / letter / A4
+ '&portrait=false' // orientation, false for landscape
+ '&fitw=true&source=labnol' // fit to page width, false for actual size
+ '&sheetnames=false&printtitle=false' // hide optional headers and footers
+ '&pagenumbers=false&gridlines=false' // hide page numbers and gridlines
+ '&fzr=false' // do not repeat row headers (frozen rows) on each page
+ '&gid='; // the sheet's Id
var token = ScriptApp.getOAuthToken();
var response = UrlFetchApp.fetch(url + url_ext + sheet.getSheetId(), {
headers : {
'Authorization' : 'Bearer ' + token
}
}).getBlob().setName(sheet.getName() + ".pdf");
// Uncomment the line below to save the PDF to the root of your drive.
// var newFile = DriveApp.createFile(response).setName(sheet.getName() + ".pdf")
if (MailApp.getRemainingDailyQuota() > 0)
GmailApp.sendEmail(email, subject, body, {
htmlBody : body,
attachments : [response],
cc : ccEmail.join(",")
});
}