I have to send a form to some people and I do it with a google script. I try to embed the form in the email with this code : https://stackoverflow.com/a/23671529/4305236:
I am sending pre-filled google form to users (partly filled and to be completed by him).
It does not send the form in the body of the email. But, it has a link which has to be clicked by the person to fill the form (some fields). Some fields are already filled by me (the sender of the email).
It is pretty straight forward.
Create the form
Fill the form values which you want to be pre-filled. Click "Get prefilled link"
Copy the url created.
USe the URL and fill the values from the google sheet.
I am enclosing the code I use
//
//
function appraisal_mail_to_all(){
//https://docs.google.com/forms/d/e/..../viewform?usp=pp_url&entry.1559436995=name&entry.226490833=Satisfactory&entry.1002429742=comment1&entry.1373188131=Poor&entry.2023543437=comment2&entry.332797694=Indifferent&entry.928578055=comment3&entry.1637933262=Poor&entry.1733301737=comment4&entry.1465918066=job_descrip&entry.31857466=1234&entry.370551729=dept&entry.835006919=qualification&entry.914497805=joined&entry.976738938=hod
var ss = SpreadsheetApp.getActiveSpreadsheet();
var activesheet=SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();
if (activesheet!=="Emp") {Browser.msgBox('Pl. click this option from "Emp" sheet');return;};
var response = Browser.msgBox('Mail Will go to all HOD.', "Are you sure ?" , Browser.Buttons.YES_NO);
if (response == "yes") {} else {return};
var empsht = ss.getSheetByName("Emp");
var emplr=empsht.getLastRow();
var empdvals = empsht.getRange("A2:W"+emplr).getValues();//all
var empcvals=ArrayLib.filterByText(empdvals, 18, "Yes");//active
var empavals=ArrayLib.filterByText(empcvals, 21, "TRUE" );//appraised
var hods = ArrayLib.unique(empavals, 16);//uniq
var joined="";
//var appss=SpreadsheetApp.openById("....");//appraisal
//var appsht=appss.getSheetByName("Form Responses 1")
//var appvals = appsht.getDataRange().getValues();
for (k=0;k<hods.length;k++){
var link1="",link2="",link3="",link4="";
var message = "Dear "+hods[k]+",<br><br>Pl. click the link to fill the performance appraisal of the people reporting to you (if pending). Pl. submit it only once per employee within two days. Once submitted, it can not be changed. Next year increment, promotion etc will be based on the appraisal. Your kind co-operation is requested.<br><br>";
message += "<table cellspacing='2' cellpadding='2' dir='ltr' border='1' style='font-size:10pt;font-family:arial,sans,sans-serif;border-collapse:collapse;border:1px solid #ccc;font-weight:normal;color:black;background-color:white;text-align:center;text-decoration:none;font-style:normal'"
+"<tr>"
+"<td bgcolor = '#ffffff', Align = 'center'>"+"<b>"+" Emp No "+"</td>"
+"<td bgcolor = '#ffffff', Align = 'center'>"+"<b>"+" Name "+"</td>"
+"<td bgcolor = '#ffffff', Align = 'center'>"+"<b>"+" Desig "+"</td>"
+"<td bgcolor = '#ffffff', Align = 'center'>"+"<b>"+" Dept "+"</td>"
+"<td bgcolor = '#ffffff', Align = 'center'>"+"<b>Link (Submit once only)"+"</b>"+"</td>"
+"</tr>"
+"<tr>"
var emps=ArrayLib.filterByText(empavals, 16, hods[k]);
var hod=ArrayLib.filterByText(empdvals,1, hods[k]);
//Browser.msgBox(hod);
//if (hod.length > 1) {Browser.msgBox(hod[0][1] + " is appearing more than once in emp master. Pl. correct it");return};
for (m=0;m<emps.length; m++){
//if (emps[m][21]==true && emps[m][18]=="Yes") {//to be appraised and active
if (emps[m][22]=="") {//appraisal not done
//if ( ArrayLib.find(appvals, 12, emps[m][0]) == 0 ) { //emp no not found in appraisal data
//if (appdone.length == 0) {//appraisal not done
//if (emps[m][15]=="") {joined=""} else { joined=Utilities.formatDate( emps[m][15],"GMT+05:30", "dd-MM-YY")} ;
link4= 'https://docs.google.com/forms/d/e/..../viewform?usp=pp_url&entry.1559436995='+emps[m][1] +'&entry.31857466='+emps[m][0]+'&entry.370551729='+emps[m][11] + '&entry.914497805='+ joined +'&entry.976738938='+emps[m][16] ;
link3 = link4.replace(/#/g, "");
link2 = link3.replace(/,/g, "");
link1 = link2.replace(/ /g, "%20");
message += "<td bgcolor = '#ffffff', Align = 'center'>"+emps[m][0]+"</td>"
+"<td bgcolor = '#ffffff', Align = 'center'>"+emps[m][1]+"</td>"
+"<td bgcolor = '#ffffff', Align = 'center'>"+emps[m][3]+"</td>"
+"<td bgcolor = '#ffffff', Align = 'center'>"+emps[m][11]+"</td>"
+"<td bgcolor = '#ffffff', Align = 'center'><a href='" +link1+ "'>click to evaluate</a></td>"
+"</tr>"
+"<tr>"
} else { //if appraisal done
//if (emps[m][15]=="") {joined=""} else { joined=Utilities.formatDate( emps[m][15],"GMT+05:30", "dd-MM-YY")} ;
message += "<td bgcolor = '#ffffff', Align = 'center'>"+emps[m][0]+"</td>"
+"<td bgcolor = '#ffffff', Align = 'center'>"+emps[m][1]+"</td>"
+"<td bgcolor = '#ffffff', Align = 'center'>"+emps[m][3]+"</td>"
+"<td bgcolor = '#ffffff', Align = 'center'>"+emps[m][11]+"</td>"
+"<td bgcolor = '#ffffff', Align = 'center'>Appraisal Completed</td>"
+"</tr>"
+"<tr>"
}//if appraisal done
//}//if to be appraised AND ACTIVE
}//for each emp under the hod
message+="</tr>"+ "</tr>"+ "</table>"+'<br>.<br><br>';
var subject1="Performance Evaluation of people under you (Confidential)";
if (hod[0][7]=="") { var hodm="..."} else {var hodm=hod[0][7]};
//var hodm="";
MailApp.sendEmail({ to: hodm, subject: subject1, htmlBody: message });
//Browser.msgBox(hodm+subject1+message)
}//for each hod
}
//
When Google sends the form to folks directly and embeds the form in the email they are using their new offering called AMP. You can read more about it here:
The code you're using gets the raw HTML of the form as it would be rendered for a user in a browser. This code is not in AMP format. Ergo it will not do what you want.
If you want that AMP experience you will need to create the AMP email yourself.
I don't think FormApp has a programatic way to send the form to folks, like you can from https://docs.google.com/forms/.
I hope that helps.