我正在尝试使用Google Forms创建一个简单的工作流程,它可以自动发送电子邮件供审批。
function sendEmail(e){
var requestorEmail = e.values[1];
Logger.log('replyEmail: ' + requestorEmail);
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/AKfycbz5GL9xxSmRcDjUFRJdn4qw7TrfaWNUFD8XwHNlqsCxNPRpOd49/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>Pend Request</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 requestorEmail = e.values[1];
Logger.log('replyEmail: ' + requestorEmail);
var aprovalResponce = (e.parameter.approval == 'true') ? 'Approved.' : 'Sorry, your request has been denied.';
var msg = "Your manager said :" + aprovalResponce;
//var replyEmail = e.values[1];
//Logger.log(replyEmail);
MailApp.sendEmail(requestorEmail, "Approval Request", msg);
var helloWorldLabel = app.createLabel(msg);
app.add(helloWorldLabel);
return app;
}
当我运行实际程序时,一切正常。但是当我收到电子邮件时,无论我点击批准还是拒绝,我都会收到一个"无效电子邮件:未定义"的错误。我是GAS的新手,研究了很多教程、示例等。但自从最近发生了重大变化以来,很少有什么有用的。
尝试将URL中的第二个问号更改为&。你现在有什么:
var approve = url + '?approval=true'+'?reply='+requestorEmail;
var reject = url + '?approval=false'+'?reply='+requestorEmail;
改变:
+'?reply='
:
+'&reply='