function sendEmail(e) {
var Email = e.values[1];
var Name = e.values [2];
var LeadEmail = e.values [3]
var StartDate = e.values[4];
var EndDate = e.values[5];
var Reason = e.values[6];
var url ='https://script.google.com/macros/s/AKfycbyzvC62Up9GS3i8SYKtjmWtEbhO5W3rhfribPES6BpYBMekNP8/exec';
var resubmitFormUrl='https://docs.google.com/forms/d/e/1FAIpQLSfNZOJRecriyYIaT2W7F08bqBlWeAgYYbv_BUpvMi2EroPLXA/viewform?usp=sf_link'
var approve = url + '?approval=approve'+'&reply='+Email;
var reject = url + '?approval=reject'+'&reply='+Email;
var moreinfo = url + '?approval=moreinfo'+'&reply='+Email;
var html ="<body>"+
"<h2>Please review</h2><br />"+
"Email id : " + Email + "<br/>"+
"Name : " + Name + "<br/>"+
"Lead Email ID: " + LeadEmail + "<br/>"+
"StartDate : " + StartDate + "<br/>"+
"EndDate : " + EndDate + "<br/>"+
"Reason : " + Reason + "<br/>"+
"<a href ="+ approve +"> Approve</a><br />"+
"<a href ="+reject+">Reject</a> <br />"+
"<a href ="+moreinfo+">MoreInfo</a> <br />"+
"</body>";
MailApp.sendEmail(LeadEmail, "Approval Request", "what no html?", {htmlBody: html});
var htmll ="<body>"+
"<h3>You have submitted these details</h3>"+
"Email id : " + Email + "<br/>"+
"Name : " + Name + "<br/>"+
"Lead Email ID: " + LeadEmail + "<br/>"+
"StartDate : " + StartDate + "<br/>"+
"EndDate : " + EndDate + "<br/>"+
"Reason : " + Reason + "<br/>"+
"<h3>You'll be notified soon about the approval decision</h3>"+
"<body/>";
MailApp.sendEmail(Email,"Approval Request","What no html?",{htmlBody:htmll});
var html2 ="<body>"+
"<h3>You have submitted the below details,but Approver require more information</h3>"+
"Email id : " + Email + "<br/>"+
"Name : " + Name + "<br/>"+
"Lead Email ID: " + LeadEmail + "<br/>"+
"StartDate : " + StartDate + "<br/>"+
"EndDate : " + EndDate + "<br/>"+
"Reason : " + Reason + "<br/>"+
"<h3>click the link </h3><a href = "+resubmitFormUrl+">Re-Submit </a> <h3>form for Approval</h3> "+
"<h3>You'll be notified soon about the approval decision</h3>"+
"<body/>";
MailApp.sendEmail(Email,"Approval Request","What no html?",{htmlBody:html2});
}
function doGet(e)
{
var answer = (e.parameter.approval==="approve") ? 'is Approved': (e.parameter.approval==="reject") ? 'Not approved' : 'Requires More Information' ;
var msg = "Your leave is: " + answer ;
if(e.parameter.approval != "moreinfo")
MailApp.sendEmail(e.parameter.reply,"Approval Request",msg);
}
This is a leave request application where user submit a form requesting for leaves. The first email the requester revives an email is acknowledgement. Also, the approve receives an email with three links, Approve, Reject and Need Info.
Issue1: The requester receives two emails an acknowledge email as well as asking the requester to provide more info.
Issue 2: When ever I hit Reject or Need Info link, the requester receives Approved email
Can you please help fix the code