【发布时间】:2020-08-26 16:06:46
【问题描述】:
这是我目前尝试使用的代码,用于根据 C2 的单元格值实现电子邮件(请参阅下面的 Google 表格屏幕截图)。
function amberwarning() {
// Fetch the combined flow value
var combflowrange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("FloodEWS").getRange("C2");
var combflow = combflowrange.getValue();
// Check combined flow value
if (270 < combflow < 310){
// Fetch the email address
var emailRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Email").getRange("A2");
var emailAddress = emailRange.getValues();
// Send Alert Email.
var subject = 'Amber warning';
var message = 'It is possible that the Egger site will experience flooding in the coming hours. The advice is to be prepared to take action as combined river flows can increase very quickly during storms. Please keep up to date with the latest river levels for Hexham at <https://flood-warning-information.service.gov.uk/station/9006>. The latest flood warnings from the Environment Agency for Hexham are here <https://flood-warning-information.service.gov.uk/warnings?location=+hexham>. The latest MetOffice weather forecast can be found here <https://www.metoffice.gov.uk/weather/forecast/gcy2xzrne#?>. Please use all available information to inform your decision making. You will keep receiving an email as per each refresh of the latest data. The current combined flow from the North and South Tyne is' + combflow;
MailApp.sendEmail(emailAddress,subject,message);
}
}
我收到的当前错误消息是“参数 (number[],String,String) 与 MailApp.sendEmail 的方法签名不匹配。(第 15 行,文件”
这个想法是: 当单元格 C2 介于 270 和 310 之间时,发送电子邮件“琥珀色警告” 当单元格 C2 高于 310 时发送电子邮件“红色警告” 当单元格 C2 小于 270 时,没有电子邮件
这有望附加到触发器上,每 15 分钟安排一次
任何关于如何合并两封电子邮件(或每封电子邮件有一个代码)的帮助将不胜感激。
【问题讨论】:
标签: email google-apps-script google-sheets