我有以下表格,其中包含多列和多行數據。我想發送包含超過 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);
});
}
在您的腳本中,以下腳本如何?
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())
qua_num
ofvar 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 個值。本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句