简体   繁体   English

有没有办法从html电子邮件获取文本字段输入值

[英]Is there a way to get text field input values from a html email

I am currently creating a leave application form using google script. 我目前正在使用Google脚本创建请假申请表。 After the user submits the form, it sends an email to a supervisor. 用户提交表单后,它将向主管发送电子邮件。 The supervisor is able to approve or reject and able to state reason of rejection from the email itself. 主管可以批准或拒绝,并可以从电子邮件本身中说明拒绝的原因。 I got the workflow all done and working, now i am just stuck at retrieving a value from a text field input in the email and set the retrieved value in a spreadsheet. 我已经完成了所有工作流程并开始工作,现在我只能从电子邮件中输入的文本字段中检索值,并在电子表格中设置检索到的值。 Any suggestions or other workarounds? 有任何建议或其他解决方法吗?

I've tried document.getElementId() but document is not defined here so... I am not too sure if the code should be in the doGet function however i dont think its likely. 我已经尝试了document.getElementId(),但是这里没有定义文档,所以...我不太确定代码是否应该在doGet函数中,但是我认为它不太可能。

function sendingEmail(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
Logger.log(sheet.getRange(25, 14).getValue());
var employeeName = e.values[1];
var email = e.values[2];
var email2 = e.values[3];
var supervisor = e.values[4];
var employeeNo = e.values[5];
var typeofLeave = e.values[6];
var leaveShift = e.values[8];
var otherReason = e.values[7];
var reason = e.values[9];
var dateFrom = e.values[10];
var dateTo = e.values[11];
var row = e.range.getRow();
var supervisoremail = sheet.getRange(row, 14);
var status = sheet.getRange(row, 13);
var rejectReason = sheet.getRange(row, 15);

var url = 'https://script.google.com/macros/s/******exec?';

var approve = url +'approval=true'+'&reply='+ email +'&reply2='+ email2 +'&row=' + row; 
var reject = url +'approval=false'+'&reply='+ email +'&reply2='+ email2 +'&row=' + row;

var html = "<body>"+
              "<h2>Please review the leave application</h2><br />"+
                "Employee Name :"+ employeeName + "<br />"+
                "Employee Email :" + email + "<br />"+
                "Employee Email opt :" + email2 + "<br />"+
                "Supervisor Name :" + supervisor + "<br />"+
                "Employee No :" + employeeNo + "<br />"+
                "Type of Leave :" + typeofLeave + "<br />"+
                "Leave Shift :" + leaveShift + "<br />"+
                "Other Reason for Leave :" + otherReason + "<br />"+
                "Reason :" + reason + "<br />"+
                "From :" + dateFrom + "<br />"+
                "To :" + dateTo + "<br />"+
                  "<a href="+approve +">Approve</a><br />"+
                    "<a href="+ reject +">Reject</a><br />"+
                    <p> //TEXT FIELD INPUT HERE
        <input type="text" value="" name="Email" placeholder="Reject  Reason" id="rejectreason"/> 
    </p>
         "</body>";
if (supervisor == 'Geralt'){
status.setValue('PENDING');
supervisoremail.setValue('GeraltofRivia@gmail.com.my'); //set supervisor emails  into spreadsheet
MailApp.sendEmail("GeraltofRivia@gmail.com.my", "Approval Request", "What no HTML?", {htmlBody: html}) 
var y = p.getElementById('rejectreason').value; //CODE ENTERS HERE?
rejectReason = setValue(y); //SETVALUE THE STRING INTO SPREADSHEET
}
else if (supervisor == 'Ciri'){
status.setValue('PENDING');
supervisoremail.setValue('Ciri@gmail.com'); //set supervisor emails into spreadsheet
MailApp.sendEmail("Ciri@gmail.com", "Approval Request", "What no HTML?",  {htmlBody: html}); /* ciri email here*/
}

email output: 电子邮件输出:
Please review the leave application 请检查请假申请

Employee Name :Yennefer
Employee Email :
Employee Email opt :yenofvengerberg@gmail.com
Supervisor Name :
Employee No :yen T138
Type of Leave :Annual Leave
Leave Shift :Full day
Other Reason for Leave :
Reason :holiday
From :12/2/2018
To :12/3/2018
Approve
Reject
Reject reason (text field)

This is what the email html looks like. 这就是电子邮件html的外观。 i wanted the string or the value from the text field to be updated in the spreadsheet once the reject/approve link is clicked. 我希望在单击拒绝/批准链接后在电子表格中更新字符串或文本字段中的值。

The short answer is no. 最简洁的答案是不。 E-mails can just show information not recieve them. 电子邮件只能显示信息,而无法接收信息。 The best option would be you put a link inside the email`s body and when the user clicks on it, its redirect the user to a page, where he can fill the fields that you're asking 最好的选择是将链接放在电子邮件正文中,当用户单击该链接时,它将用户重定向到页面,他可以在该页面中填写您要询问的字段

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM