我想通过电子邮件发送html表单,我希望在邮件撰写时动态填写几个输入字段,而不设置'值'每次都以编程方式归属。
我在Gsheet的脚本中制作了html表单电子邮件模板,通过gsheet发送邮件,我将其提交到google应用程序脚本Web应用程序,该应用程序获取表单数据并将其存储到google工作表中。 这是我的表格脚本
function onOpen(){
SpreadsheetApp.getUi().createMenu("Send Mail").addItem("Feedback Mail", "feedbackMail").addToUi();
}
function feedbackMail(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getActiveSheet();
var row = sh.getActiveRange().getRow();
var clientName = sh.getRange("A"+row).getDisplayValue();
var senderID = Session.getActiveUser().getEmail();
var clientID = sh.getRange("B"+row).getDisplayValue();
var senderName = sh.getRange("C"+row).getDisplayValue();
var service = sh.getRange("D"+row).getDisplayValue();
var sub= sh.getRange("E"+row).getDisplayValue();
var message = "";
var date = new Date();
var messageHTML = composeHtmlMsg(clientID,clientName,senderName,senderID,service,date);
Logger.log(messageHTML);
MailApp.sendEmail(clientID,sub,message,{'htmlBody':messageHTML});
}
function composeHtmlMsg(clientID,clientName,senderName,senderID,service,date){
var message = "<form action= 'https://script.google.com/macros/s/AKfycbx67anh324kurjh_EU65BL7y9v50lPuQFnVvUvcuIwQsjYn3VRl/exec' method='GET'><input type='email' name='clientID' value='"+clientID+"'><input type='email' name='senderID' value='"+senderID+"'><input type='text' name='senderName' value='"+senderName+"'><input type='text' name='clientName' value='"+clientName+"'><input type='datetime' name='datetime' value='"+date+"'><br>"
+"Hi "+clientName+",<br><br>"
+"Thank you for trusting us with your "+service+" needs.we constantly strive to provide excellent services and make our clients happy.<br>"
+"If you have a few moments, we’d love to get your feedback with a brief survey.<br>"
+"<pre><b>Overall, how satisfied are you with our services?</b> "
+"Very Happy "
+"<input type='radio' name='response1' value='Very Happy'> "
+"Happy "
+"<input type='radio' name='response1' value='Happy'> "
+"Just Satisfied "
+"<input type='radio' name='response1' value='Just Satisfied'> "
+"Not Happy "
+"<input type='radio' name='response1' value='Not Happy'><br><br>"
+"<b>How satisfied are you with representatives?</b> "
+"Very Happy "
+"<input type='radio' name='response2' value='Very Happy'> "
+"Happy "
+"<input type='radio' name='response2' value='Happy'> "
+"Just Satisfied "
+"<input type='radio' name='response2' value='Just Satisfied'> "
+"Not Happy "
+"<input type='radio' name='response2' value='Not Happy'><br><br>"
+"<b>How satisfied are you with the process?</b> "
+"Very Happy "
+"<input type='radio' name='response3' value='Very Happy'> "
+"Happy "
+"<input type='radio' name='response3' value='Happy'> "
+"Just Satisfied "
+"<input type='radio' name='response3' value='Just Satisfied'> "
+"Not Happy "
+"<input type='radio' name='response3' value='Not Happy'><br><br>"
+"<b>Do you think we keep you adequately informed on all issues?</b> "
+"Very Happy "
+"<input type='radio' name='response4' value='Very Happy'> "
+"Happy "
+"<input type='radio' name='response4' value='Happy'> "
+"Just Satisfied "
+"<input type='radio' name='response4' value='Just Satisfied'> "
+"Not Happy "
+"<input type='radio' name='response4' value='Not Happy'><br><br>"
+"<b>What can we improve about our services?</b><br><br>"
+"<textarea name='message' rows='4' cols='50'></textarea><br><br></pre>"
+"<input type='submit' value='Submit'><br><br>"
+"</form>"
+"Thank you for your time !<br><br>"
return message;
}
这是我的网络应用代码
function doGet(e) {
var clientName = e.parameter.clientName;
var clientID = e.parameter.clientID;
var senderName = e.parameter.senderName;
var senderID = e.parameter.senderID;
var date = e.parameter.datetime;
var response1 = e.parameter.response1;
var response2 = e.parameter.response2;
var response3 = e.parameter.response3;
var response4 = e.parameter.response4;
var response5 = e.parameter.message;
var sheet = SpreadsheetApp.openById("ID HiDDEN").getSheetByName("Responses").appendRow([clientName,clientID,senderName,response1,response2,response3,response4,response5,date]);
return ContentService.createTextOutput('Thank You for your valuable feedback').setMimeType(ContentService.MimeType.TEXT)
}
现在我想切断使用谷歌电子表格发送邮件。我想发送带有集成在gmail应用程序中的此表单的电子邮件(普通邮件撰写程序)。此外,我希望表单在clientID,clientName等中插入动态不同的值。在发送的每封邮件的邮件撰写时间。
但问题是我们在表单字段中输入值并发送邮件。价值观丢失了。