google-apps-script - 从 webapp 调用的函数不发送电子邮件
问题描述
我在使用 Google 脚本时遇到问题。
我正在尝试做一个开放式问卷调查,允许匿名文件上传到我的谷歌驱动器上的特定文件夹,然后向我发送一封通知电子邮件到我的邮件。它可以正常上传文件,但未发送电子邮件。
在调试模式下,它发送了电子邮件。
这是我的代码:
<form id="myForm">
<input type="text" name="myName" placeholder="Su Nombre..">
<input type="file" name="myFile">
<input type="submit" value="Subir Archivo"
onclick="this.value='subiendo..';
google.script.run.withSuccessHandler(fileUploaded)
.uploadFiles(this.parentNode);
return false;">
</form>
和谷歌脚本文件:
function doGet(e) {
return HtmlService.createHtmlOutputFromFile('form.html');
}
function uploadFiles(form) {
try {
var folder = DriveApp.getFolderById(/*folder id*/);
var blob = form.myFile;
var file = folder.createFile(blob);
file.setDescription("Subido Por " + form.myName);
// email
var asunto = "Testing attaching file";
var correo = /*my email address*/;
var options = {attachment : [form.MyFile]};
MailApp.sendEmail(correo, asunto, emailBody, options);
return "Archivo Subido Con Exito " + file.getUrl();
}
catch (error) {
return error.toString();
}
}
解决方案
推荐阅读
- c++ - 嵌套 if...else 语句如何优于 C++ 中的一系列单选 if 语句
- php - Codeigniter 无效链接作为有效链接打开
- c++ - 为什么带有多个 copy_n() 的 std::istream_iterator<> 总是写入第一个值
- javascript - 如何仅获取元素文本的前 5 个字符?
- c# - Json.Net:如何忽略数组反序列化 JSON 中的空元素
- apache-spark - Spark迭代算法UDF在每次迭代中被多次触发
- asynchronous - netlink 是同步还是异步协议?
- powershell - 按部门属性及其在 SCCM 中的资源名称比较 AD 用户的报告
- nginx - 'init_by_lua_block' 指令未在 nginx 启动时执行
- vert.x - Quarkus + Vertx 的性能不如单独的 Vertx