我有以下表格,其中包含多列和多行資料。我想發送包含超過 1 列(A 列和 D 列)中的資料的電子郵件警報,目前我已經能夠針對 1 列(A 列)中的資料實作這一點。我們如何在 google 腳本中映射多列并將資料添加到電子郵件中?
提前致謝。

function sendEmails()
{
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 1; // First row of data to process
var numRows = 300; // Number of rows to process
// Fetch the range of cells A1:P300
var dataRange = sheet.getRange(startRow, 1, numRows, 16);
// Fetch values for each row in the Range.
var data = dataRange.getValues();
var dayofemail = data[0][15];
data.reduce((m, [qua_num,,,,,,,,daysPastCal,emailAddress]) => {
if (daysPastCal > -14) m.set(emailAddress, m.has(emailAddress) ? [...m.get(emailAddress), qua_num] : [qua_num]);
return m;
}, new Map())
.forEach((qua_num, emailAddress) => {
var message = qua_num.join("\n") '\nThe above equipment are approaching due date or out of cal.\nPlease check with QA for replacement or sending the equipment out for re-calibration.';
var subject = 'AUTOMATED ALERT: CHECK EQUIPMENT CALIBRATION ';
MailApp.sendEmail(emailAddress, subject dayofemail, message);
});
}
uj5u.com熱心網友回復:
在您的腳本中,以下腳本如何?
從:
data.reduce((m, [qua_num,,,,,,,,daysPastCal,emailAddress]) => {
if (daysPastCal > -14) m.set(emailAddress, m.has(emailAddress) ? [...m.get(emailAddress), qua_num] : [qua_num]);
return m;
}, new Map())
到:
data.reduce((m, [qua_num, , , serial, , , , , daysPastCal, emailAddress]) => {
if (daysPastCal > -14) m.set(emailAddress, m.has(emailAddress) ? [...m.get(emailAddress), qua_num, serial] : [qua_num, serial]);
return m;
}, new Map())
- 通過這種修改,添加了“D”列的值。所以,
qua_numofvar message = qua_num.join("\n") '\nThe above equipment are approaching due date or out of cal.\nPlease check with QA for replacement or sending the equipment out for re-calibration.'有列“A”和“D”的 2 個值。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/360224.html
上一篇:為什么ContactsApp.getContactsByEmailAdress('[email protected]')使用GoogleApps腳本回傳[Contact]?
