为什么 Google 电子表格脚本中的 MailApp.sendEmail 不起作用?

Why does MailApp.sendEmail from Google Spreadsheet Script not Work?

我正在尝试按照这个示例在Google电子表格脚本中使用MailApp.sendEmail发送电子邮件: https://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/ by @mhawksey

see: https://docs.google.com/spreadsheets/d/1mhY_hJMMPTmxq3TFAUHK0tKFhGYBpzus-dXE3U5TQdc/edit?usp=sharing

针对您的最新代码测试网络应用程序。 函数 有效 。 (电子邮件已发送

但是当我尝试通过 POST 请求触发 sendEmail() 时,它不起作用。

我正在关注文档: https://developers.google.com/apps-script/reference/mail/mail-app

然而,当我从我的脚本中触发 sendEmail() 函数时,它没有发送电子邮件。

我做错了什么?

看过:

但是我想理解如果我做错了什么...

完整步骤和代码:https://github.com/nelsonic/web-form-to-google-sheet#12-google-apps-script

Thanks to @ZigMandel for pointing me the right direction ... here are the steps for anyone else facing this issue:

调用MailApp.sendEmail方法

在您的 Google 电子表格 Script 调用中:

MailApp.sendEmail("recipient.address@gmail.com", // to
                  "sender.name@gmail.com",       // from
                  "Your Subject Goes Here",      // email subject
                  "What ever you want to say");  // email body

根据文档:https://developers.google.com/apps-script/reference/mail/mail-app#sendemailto-replyto-subject-body

要在您的脚本中发挥这一新功能,您 将需要“保存新版本”和(重新)部署您的应用程序! (只需单击 "Save" 是 不够!)

保存脚本的新版本

不会立即显而易见,但您必须单击管理版本..." 请参阅:https://developers.google.com/apps-script/guide_versions

然后创建你的新版本:

更新的脚本重新发布为网络应用程序

Select要部署的最新项目版本:

单击 "OK"。无需更新 HTML 表单中的脚本 url它不会改变 - 这有利有弊...

完成。

完整的解决方案请参阅:https://github.com/nelsonic/web-form-to-google-sheet