更改Google脚本工作流程应用中的自动电子邮件

时间:2014-11-26 21:55:16

标签: google-app-engine

大家好我正在尝试修改以下google脚本工作流程(来自http://www.youtube.com/watch?v=eduG0XZ9mDs&feature=plcp)。我正在尝试更改自动生成的电子邮件的内容。我尝试更改代码中的文本(即从“购买它!”到“此请求未被批准”。但无论我做什么,电子邮件都会与原始文本一起发送。我在这里做错了什么?

谢谢!

function sendEmail(e) {
  var email = e.values[1];
  var Item = e.values[2];
  var cost = e.values[3];  
  var url = '<ENTER YOUR PUBLISHED URL>';  
  var approve = url + '?approval=true'+'&reply='+email; 
  var reject = url + '?approval=false'+'&reply='+email;

  var html = "<body>"+
            "<h2>Please review</h2><br />"+
            Item +": " + cost+ "<br />"+ 
            "<a href="+ approve +">Approve</a><br />"+
            "<a href="+ reject +">Reject</a><br />"+
         "</body>";

  MailApp.sendEmail("jjones@beaconcloudsolutions.com", "Approval Request", 
                "What no html?", {htmlBody: html});  
}

function doGet(e){ 
  var answer = (e.parameter.approval == 'true') ? 'Buy it!' : 'Not this time, Keep saving';   
  MailApp.sendEmail(e.parameter.reply, "Purchase Request", 
                "Your manager said: "+ answer);     
  var app = UiApp.createApplication();
 app.add(app.createHTML('<h2>An email was sent to '+ e.parameter.reply + ' saying: '+ answer + '</h2>'))
  return app
}

1 个答案:

答案 0 :(得分:0)

我认为您应该记录您的代码。所以你可以知道以下内容的价值:e.parameter.approval,answer等。

但是根据我的观察,尝试更改你的html var,所以它会像:

var html = "<body>"+
        "<h2>Please review</h2><br />"+
        Item +": " + cost+ "<br />"+ 
        "<a href='"+ approve +"'>Approve</a><br />"+
        "<a href='"+ reject +"'>Reject</a><br />"+
     "</body>";

我希望它能解决问题。