我希望在“已批准”并分配“工作单#”后将表单回复通过电子邮件发送给帮助台电子邮件,这意味着我打开电子表格并将批注名称分配给已批准的列并为其分配工单号。新工单列。我已经修改了许多脚本来尝试实现这一目标。我不希望在提交表单时立即发送回复,因为他们至少需要附上工作订单。下面是我试图修改的脚本(如下所示,未经任何修改)。如果我希望表单提交在用户点击提交时直接转到电子邮件,它工作正常。同样,仅当工作订单附加到电子表格中的相应订单项时,我才需要通过电子邮件发送它们。
function nl2br_(input_string){
return input_string.replace(/(\r\n|\r|\n)/g,'<br />');
}
function RequestNWOMailer(e) {
try {
var recipient = 'test-area@efriends44221.org';
var timestamp = e.values[0];
var name = e.values[1];
var contactmethod = e.values[2];
var emailphone = e.values[3];
var building = e.values[4];
var room = e.values[5];
var reason = e.values[6];
var description = e.values[7];
var approval = e.values[8];
var nwo = e.values[9];
var subject = building+' <'+reason+'> <'+name+'>';
var body = name+' <'+emailphone+'> sent the following: '+description;
var bodyHTML = '\
<p>NWO #: '+nwo+'</p>\
<p>'+name+' sent the following: </p>\
<p>Contact Method: '+contactmethod+'</p>\
<p>Email of Phone#: '+emailphone+'</p>\
<p>Building: '+building+'</p>\
<p>Room #: '+room+'</p>\
<p>Reason for NWO: '+reason+'</p>\
<p>Description: '+nl2br_(description)+'</p>';
var advancedArgs = {htmlBody:bodyHTML , replyTo:emailphone};
MailApp.sendEmail(recipient, subject, body, advancedArgs);
} catch(e){MailApp.sendEmail(recipient, "Error - Request for New Work Order Form", e.message);
}
}