【问题标题】:Google App Script, TextOutput doesnt return message谷歌应用脚​​本,TextOutput 不返回消息
【发布时间】:2021-08-01 14:05:41
【问题描述】:

故事: 我正在测试一个 google 应用程序脚本,它接收文件并向收件人发送包含文件内容作为邮件正文的电子邮件。我还想让发件人/用户知道“电子邮件发送成功”

问题: 一切正常,直到到达最后一行,

return ContentService.createTextOutput("sent successfully!!!");

它应该将成功消息返回给发件人。但它发送http状态错误[302]。我正在使用 dio 包发送 http post 请求。我也单独测试了返回线,效果很好。

function doPost(e) {
  var blob = Utilities.newBlob(Utilities.base64DecodeWebSafe(e.parameter.file),e.parameter.contentType,e.parameter.fileName);
  var body = blob.getDataAsString();
  MailApp.sendEmail("testEmail@gmail.com", "this is a test subject", body);
  return ContentService.createTextOutput("sent successfully!!!"); //doesnt work
}

这段代码运行良好:

function doGet() {
  return ContentService.createTextOutput("hello world!");
}

我做错了什么?

【问题讨论】:

    标签: google-apps-script


    【解决方案1】:

    e.parameterGET参数,通常用于GET请求

    你应该使用e.postData

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-10
      • 1970-01-01
      • 2021-02-26
      • 2023-03-11
      • 1970-01-01
      • 2014-08-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多