将电子邮件中的链接指向无效的Google网址

时间:2015-06-01 17:10:56

标签: html user-interface google-apps-script google-apps google-form

我正在尝试使用Google表单创建一个简单的工作流程,该表单会发送自动电子邮件以供审批。

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的新手,并且已经研究过很多教程,例子等等。但是,由于最近发生了很大的变化,所以很少有帮助。

1 个答案:

答案 0 :(得分:0)

尝试将网址中的第二个问号更改为&符号。你现在拥有什么:

+'?reply='

变化:

+'&reply='

要:

e.preventDefault()