I'm trying to use Apps script to embed a prefilled Form in an email. The emails will only be sent to Gmail users. I want something that works the same as pressing the 'include form in email' option when manually emailing a form.
I've successfully created the prefilledUrl
and used UrlFetchApp
and HtmlService
to get the Html from the form and send email.
But when it arrives it looks like the screenshot below and user can not submit.
A stripped down version of the code I am using is the following:
var prefilledForm = 'prefilledForm link here');
Logger.log(prefilledForm);
var subject = 'Message from Office';
var response = UrlFetchApp.fetch(prefilledForm);
var htmlBody = HtmlService.createHtmlOutput(response).getContent();
var body = 'Dear '+mName+',\n\n'+mMessage+'\nPlease acknowledge by submitting the form below.\nRegards,\nSchool Office';
GmailApp.sendEmail(eEmail,subject,body,{
noReply:true,
htmlBody: htmlBody
});
Is there anyway to embed the form in an email just like it does when you select 'include form in email' like the screenshot below?