Here is the code:
const ss = SpreadsheetApp.getActiveSpreadsheet();
const ws = ss.getSheetByName("StudentReport_all");
const range = ws.getRange(4,1,ws.getLastRow(),ws.getLastColumn());
const data = range.getValues();
var form = FormApp.openById("154QspMd1P4RmTRDnOQHL06dU-KvL8FPU53wHYcar09U");
//form.setRequireLogin(true);
var formUrl = form.getPublishedUrl();
var title = form.getTitle();
var descriptionText = form.getDescription();
function sendForm() {
var subject = "Response Needed: " + form.getTitle()
var response = UrlFetchApp.fetch(formUrl);
var template = HtmlService.createHtmlOutput(response);
//var htmlBody = HtmlService.createHtmlOutputFromFile("teacherEmail").getContent();
var htmlBody = template.getContent();
//HtmlService
var p1Email = data[9][3];
var p2Email = data[10][3]
var p3Email = data[11][3]
var p4Email = data[12][3]
var p5Email = data[13][3]
var p6Email = data[14][3]
GmailApp.sendEmail(
[p1Email],
subject,
htmlBody
)
return htmlBody
Logger.log(htmlBody);
}
When I click the button in Google Sheets, an email should send to the entered emails and the google form template should show up in the email. But when I click the button, instead of the google form template, the raw html shows up. How do I fix this?