我的脚本有问题。当我尝试运行该程序时,出现错误消息。 “找不到脚本函数:myFunction”
我需要知道为什么它不起作用,或者有更好的方法来编写我想做的事情。
function onEdit(e){
var sheetName = "Summary1";
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(sheetName);
if(sheet.getActiveCell().getColumn() == 8 && sheet.getRange(sheet.getActiveCell().getRow(), 1).getValue() != 0)
{
var sendMail = Browser.msgBox("Would you like to send an email", Browser.Buttons.YES_NO);
if(sendMail == "Yes")
{
var subject = sheet.getRange(sheet.getActiveCell().getRow(), 10).getValue();
var body = sheet.getRange(sheet.getActiveCell().getRow(), 11).getValue();
MailApp.sendEmail("email@gmail.com", subject, body);
}
}
else if(sheet.getActiveCell().getColumn() == 12 && sheet.getRange(sheet.getActiveCell().getRow(), 1).getValue() != 0)
{
var sendMail1 = Browser.msgBox("Would you like to send an email", Browser.Buttons.YES_NO);
if(sendMail1 == "Yes")
{
var subject1 = sheet.getRange(sheet.getActiveCell().getRow(), 13).getValue();
var body1 = sheet.getRange(sheet.getActiveCell().getRow(), 14).getValue();
var mail1 = sheet.getRange(sheet.getActiveCell().getRow(), 9).getValue();
MailApp.sendEmail(mail1, subject1, body1);
}
}
else if (sheet.getActiveCell().getColumn() == 17 && sheet.getRange(sheet.getActiveCell().getRow(), 1).getValue() != 0)
{
var sendMail2 = Browser.msgBox("Would you like to send an email", Browser.Buttons.YES_NO);
if(sendMail2 == "Yes")
{
var subject2 = sheet.getRange(sheet.getActiveCell().getRow(), 15).getValue();
var body2 = sheet.getRange(sheet.getActiveCell().getRow(), 16).getValue();
var mail2 = sheet.getRange(sheet.getActiveCell().getRow(), 9).getValue();
MailApp.sendEmail(mail2, subject2, body2);
}
}
}