请帮助我#34;电子邮件"问题?我写了代码,在更改值后自动发送电子邮件到帐户。发送电子邮件的功能很好(从Google Script IDE运行后),但是当它在电子表格中更改值后自动发送电子邮件时,我没有收到任何电子邮件。 你能查一下我的代码吗?调试消息显示正常。所以我有点失落。
这是代码:
function sendEmail(message) {
Browser.msgBox(message); //Debug Message
var emailAddress = "[email address]";
var subject = "Sending emails from a Spreadsheet";
MailApp.sendEmail(emailAddress, subject, message);
}
function onEdit(event) {
var sheet = event.range.getSheet();
if(sheet.getName() == "Hunting List"){
// correct sheet
var cell = event.range;
//var cellR = cell.getRow(); // not used at this time
var cellC = cell.getColumn();
var cellValue = event.value;
if (cellC == 8) {
if(cellValue=="Won"){
Browser.msgBox(cellValue); //Debug Message
sendEmail("Congratulation, we gained new client!");
}
}
}
}
答案 0 :(得分:0)
对于你的onEdit试试这个
function onEdit(event) {
var sheet = event.source.getActiveSheet();
if (sheet.getName() !== "Hunting List" || event.range.columnStart !== 8) return;
if (event.value == "Won") sendEmail("Congratulation, we gained new client!");
}