Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
How do I make the JavaScript code using the HtmlService class output as a google form in email when a button is clicked instead of raw html?

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?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda