【问题标题】:Why does MailApp.sendEmail from Google Spreadsheet Script not Work?为什么 Google 电子表格脚本中的 MailApp.sendEmail 不起作用?
【发布时间】:2015-10-16 21:57:44
【问题描述】:

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

见: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

【问题讨论】:

  • 您是否收到错误消息?你能用一个简单的脚本重现这个问题吗?
  • 您很可能忘记保存新版本并使用该版本发布。请参阅官方帮助中的版本控制。
  • @ZigMandel 谢谢!!对于其他人:developers.google.com/apps-script/guide_versions

标签: google-apps-script google-sheets google-docs google-apps


【解决方案1】:

感谢@ZigMandel 为我指出了正确的方向 ...以下是其他面临此问题的人的步骤:

调用MailApp.sendEmail 方法

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

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

为了让这个新功能在您的脚本中工作,您 将需要“保存新版本”并(重新)部署您的应用! (只需点击“保存” 还不够!)

保存一个新版本你的脚本

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

然后创建你的新版本:

更新的脚本重新发布为 Web 应用

选择要部署的最新项目版本:

点击“确定”。无需更新 HTML 表单中的脚本 url它不会改变 - 这有利有弊......

完成。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-22
    相关资源
    最近更新 更多