【发布时间】:2020-08-26 14:28:26
【问题描述】:
我是 Google 脚本的初学者,希望根据 Google 表格中的单元格值发送电子邮件。
确定是否要发送电子邮件的单元格是工作表“FloodEWS”中的 C2。
如果值等于或大于 270,我需要发送特定的电子邮件。 如果值等于或大于 310,我需要发送不同的电子邮件。
我目前的脚本是这样的:
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 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;
var subject = 'Amber flood warning';
MailApp.sendEmail(emailAddress, subject, message);
}
}
任何帮助将不胜感激。
【问题讨论】:
标签: json google-apps-script google-sheets conditional-formatting