简体   繁体   English

使用doGet()发送参数时,Google Apps脚本Web App MailApp / GmailApp.sendMail()不起作用

[英]Google Apps Script Web App MailApp/GmailApp.sendMail() not working when parameter is sent using doGet()

function doGet(e) {
  var email = e.parameter.method;
  var subject = "Hello";
  var body = "Hi, I am ";
  MailApp.sendEmail(email, subject, body);
  Logger.log(e.parameter.method);
}

Above is my Apps Script published as a web app. 上面是我作为网络应用发布的Apps脚本。 Logger is working fine, but the mail is not being sent. 记录器工作正常,但未发送邮件。 I am trying to run the script by browser, going to following link. 我正在尝试通过浏览器运行脚本,请转到以下链接。 I was expecting a mail to be sent to some.body from my mail. 我原本希望将邮件从我的邮件发送给某人。 I have already authorized the script to send my mails. 我已经授权脚本发送我的邮件。

https://script.google.com/macros/s/[---my script--- ]/exec?method=some.body@gmail.com

Put this in a try-catch block to catch the exact error. 将其放在try-catch块中以捕获确切的错误。 You may also want to test for your email quota. 您可能还需要测试您的电子邮件配额。

function doGet(e) {
 try {
  var email = e.parameter.method;
  var subject = "Hello";
  var body = "Hi, I am ";
  MailApp.sendEmail(email, subject, body);
  Logger.log(e.parameter.method);
  Logger.log(MailApp.getRemainingDailyQuota());
 } catch (error) {
 Logger.log(error.toString());
 }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 谷歌广告脚本是否支持 GmailApp.sendmail ...? - Is google ads script support GmailApp.sendmail …? Google 脚本:仅在使用 Web 应用程序时找不到 doGet 函数? - Google script: doGet function not found only when using web app? Google Apps Script - 在 doGet() 网络应用程序中格式化打印页面 - Google Apps Script - Formatting printed page in doGet() web app 来自网页的 Google Apps 脚本 GmailApp - Google Apps Script GmailApp from Web Page 每次发送包含 Web 应用程序的嵌入式链接的草稿时,如何阻止请求发送到 doGet(e)? (Google Apps 脚本) - How to stop a request from going out to doGet(e) every time a draft containing embedded link to web app is SENT? (Google Apps Script) Google Apps 脚本 - MailApp - Google Apps Script - MailApp Google Apps脚本mailApp.sendEmail无法正常工作 - Google Apps Script mailApp.sendEmail Not working 在Google脚本中,MailApp.sendEmails()和GmailApp.sendEmails()无法正常工作。 有任何解决或解决的建议吗? - In Google Script, MailApp.sendEmails() and GmailApp.sendEmails() is not working. Any suggestions to fix or work around? google apps脚本doGet - google apps script doGet Google Apps脚本:使用mailapp.sendmail服务发送仅带有偶尔附件的邮件 - Google apps script: use the mailapp.sendmail service to send mails with only occasional attachments
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM