因此,我正致力于为Google表单创建此批准工作流程。我是新手,我已经在线搜索并阅读了一些教程以及谷歌的内容,但我见过的大部分内容都已被弃用。我认为我的触发器是最新的,它们设置为onformsubmit,当我检查执行日志时,它表示成功。但是,我还没有收到任何电子邮件。任何人都可以带领我朝着正确的方向前进吗?
谢谢!
function sendEmail(e){
var requestorEmail = e.values[1];
var SupervisorsEmail = e.values[2]; //manager e-mail
var ApplicationID = e.values[3];
var ApplicationDate = e.values[4]; //dateconfirmationSent
var ApplicantName = e.values[5]; //interpreter name
var MBO = e.values[6];
var Processor = e.values[7];
var ShortReason = e.values[8];
var ReasonCode = e.values[9];
var approval = e.values[10]; //the one we need to modify
var url ='https://script.google.com/a/macros/bbva.com/s/AKfycbwKtqBa7L_oB2qnkQclVmKuWLnxj6ic74CAalUmxEDCv0SkjCY/exec';
/**might be that the & needs to be a ?*/
var approve = url + '?approval=true'+'?reply='+requestorEmail;
var reject = url + '?approval=false'+'?reply='+requestorEmail;
var html = "<HTML><body>"+
"<h2>please review</h2><br />"
+"<P>" + ApplicationID +" " + ApplicationDate
+"<p>" + "MBO:"+ MBO
+"<p>" + "Processor:" + Processor
+"<p>" + "Short Reason: "+ ShortReason
+"<p>" + "requester: "+ requestorEmail+
+"<p>" + "Reason Code: "+ ReasonCode+ " "+
"<p>"+
"<a href="+ approve +">Approve</a><br />"+
"<p>"+
"<a href=" +reject+">Reject</a><br />"+
"</HTML></body>";
MailApp.sendEmail(SupervisorsEmail, "Approval Request", "what no html?", {htmlBody: html});
}
function doGet(e) {
var app = UiApp.createApplication();
var aprovalResponce = (e.parameter.approval == 'true') ? 'Approved.' : 'Sorry, you need to reschedule';
var msg = "Your manager said :" + aprovalResponce;
var replyEmail = e.parameter.reply;
Logger.log(replyEmail);
MailApp.sendEmail(replyEmail, "Approval Request", msg);
var helloWorldLabel = app.createLabel(msg);
app.add(helloWorldLabel);
return app;
}
这是我的执行记录
[15-05-28 11:24:54:243 CDT] SpreadsheetApp.getActiveRange() [0 seconds]
[15-05-28 11:24:54:243 CDT] Range.getRow() [0 seconds]
[15-05-28 11:24:54:243 CDT] Range.getLastRow() [0 seconds]
[15-05-28 11:24:54:243 CDT] Range.getColumn() [0 seconds]
[15-05-28 11:24:54:244 CDT] Range.getLastColumn() [0 seconds]
[15-05-28 11:24:54:244 CDT] SpreadsheetApp.getActiveSpreadsheet() [0 seconds]
[15-05-28 11:24:54:283 CDT] Starting execution
[15-05-28 11:24:54:713 CDT] MailApp.sendEmail(i removed personal info) [0.425 seconds]
[15-05-28 11:24:54:714 CDT] Execution succeeded [0.426 seconds total runtime]
电子邮件目前正在运行,但现在我点击了#34;批准&#34;在我的电子邮件中。有什么想法吗?
[15-05-28 16:19:46:941 CDT] Starting execution
[15-05-28 16:19:46:965 CDT] UiApp.createApplication() [0.001 seconds]
[15-05-28 16:19:46:967 CDT] Logger.log([undefined, []]) [0 seconds]
[15-05-28 16:19:46:968 CDT] MailApp.sendEmail([undefined, Approval Request, Your manager said :Sorry, you need to reschedule]) [0 seconds]
[15-05-28 16:19:46:992 CDT] Execution failed: Invalid email: undefined (line 52, file "Code", project "Send emails") [0.006 seconds total runtime]
答案 0 :(得分:1)
即使您确实从表单中获得了所需的电子邮件,也请尝试“硬编码”#39;和电子邮件,看看MailApp.sendEmail()
功能是否有效:
MailApp.sendEmail('email@gmail.com", "Approval Request", "what no html?", {htmlBody: html});
在这行代码之后:
var SupervisorsEmail = e.values[2]; //manager e-mail
输入Logger.log()
声明:
var SupervisorsEmail = e.values[2]; //manager e-mail
Logger.log('SupervisorsEmail: ' + SupervisorsEmail);
然后提交表单,并在VIEW菜单和LOGS下查看。你收到了电子邮件吗?
另外,请查看发送的&#39;文件夹,查看是否有电子邮件已发送,但从未收到过。