【问题标题】:Google Apps Script: How to send a mail after a cell is edited?Google Apps 脚本:编辑单元格后如何发送邮件?
【发布时间】:2021-07-28 22:21:56
【问题描述】:

我有一个空的 Google 电子表格 和以下工作 Apps 脚本代码

// This function SUCCESSFULLY opens a message box whenever a cell is edited, it shows the row of the edited cell.
function onEdit(e) {
  Browser.msgBox(e.range.getRow());
}

// This function SUCCESSFULLY sends an email to 'john@doe.com' (this email address is changed for an actual registered address) upon being called.
function myTestFunction() {
  MailApp.sendEmail('john@doe.com', 'Test', 'Cell changed');
}

但是,如果我将“onEdit”功能更改为以下内容,它将无法正常工作:

// This function SUCCESSFULLY opens a message box whenever a cell is edited, BUT IT DOES NOT SEND AN EMAIL.
function onEdit(e) {
  Browser.msgBox(e.range.getRow());
  MailApp.sendEmail('info@bpbl.de', 'Test', 'Cell changed');
}

为什么后者的“onEdit”功能不发送电子邮件?

(是的,我检查了我的remaining daily email quota,还有很多。)

【问题讨论】:

标签: email google-apps-script google-sheets send


【解决方案1】:

这个问题已经发布了,很遗憾,你不能在简单的触发器 onEdit 中调用 sendEmail 函数:(

Google-apps-script will not send email inside an onEdit function

https://developers.google.com/apps-script/guides/triggers

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-21
    • 2023-01-20
    相关资源
    最近更新 更多