MailApp.sendEmail不会触发 [英] MailApp.sendEmail not firing

查看:74
本文介绍了MailApp.sendEmail不会触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在onEdit(event)中调用函数时,下面的函数似乎没有触发任何类型的电子邮件。我已经尝试了EmailApp和GmailApp,对此事的任何帮助将不胜感激。



我也尝试使用我的个人@ gmail.com帐户,
$ b

 函数sendAlert(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var cell = ss.getActiveCell()。getA1Notation()

var subject ='Update to'+ sheet.getName();
var body = sheet.getName()+'已更新。访问'+ ss.getUrl()+'以查看单元格+ cell的更改;
GmailApp.sendEmail('s .... @ project-la.com',subject,body);
};


解决方案

您的函数 sendAlert )从 onEdit()函数调用

简单的onEdit函数无法发送邮件,详见文档。因此,请使用可安装的onEdit触发器。

触发器位于脚本编辑器的资源选项卡中,它看起来像这样:
< img src =https://i.stack.imgur.com/1HEPH.jpgalt =在这里输入图片描述>



注意:如果你是使用现有的 onEdit()函数,请记住重命名它,以便它不再作为简单的触发器函数。


My function below doesn't seem to be firing off any sort of email when the function is called in onEdit(event). I have tried both EmailApp and GmailApp, any help on the matter would be greatly appreciated.

I have also tried to use my personal @gmail.com account and neither will send an email to it again.

function sendAlert() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getActiveSheet();
  var cell = ss.getActiveCell().getA1Notation()

  var subject = 'Update to '+sheet.getName();
  var body = sheet.getName() + ' has been updated.  Visit ' + ss.getUrl() + ' to view the changes on cell ' + cell;
  GmailApp.sendEmail('s....@project-la.com', subject, body);
};

解决方案

Is your function sendAlert() called from an onEdit() function?

The simple onEdit function is unable to send mails, as is described in the documentation. Therefore, use an installable onEdit trigger instead. This last one will ask for authorization and then execute as expected.

The triggers are in the ressource tab in the script editor, it looks like this:

Note: If you are re-using an existing onEdit() function, remember to rename it so it will no longer act as a simple trigger function.

这篇关于MailApp.sendEmail不会触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆