Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

295
Vistas
Google App Script Error - Cannot read property 'response' of undefined and Failed to send email: no recipient

I have a simple script that executes once form submit. It is a simple test script applied html for email.

function sendEmail(e) {
  
  //response
  //getRespondentEmail()
  var html = HtmlService.createTemplateFromFile("email.html");
  var htmlText = html.getCode();
  
  var emailTo = e.response.getRespondentEmail();
  var subject = "Thanks for participating";
  var textBody = "This email requries HTML support, please maek sure you open with a client taht support.";
  var options = { htmlBody: htmlText };
  
  
  if(emailTo !== undefined){
    GmailApp.sendEmail(emailTo,subject,textBody,options);
  //(recipient, subject, body, options)
  }
}

But it always noticed TypeError: Cannot read property 'response' of undefined.

TypeError: Cannot read property 'response' of undefined (line 8, file "Code")

either the respose from my host email said 'Failed to send email: no recipient' enter image description here

I do not know why it does not work, but I see someone successfully applied through above google app script.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

'e' undefined:

TypeError: Cannot read property 'response' of undefined

This error means the parameter e is undefined. Which means this function is not executing via trigger.

When functions are called by triggers, the function is passed an event object as argument. But in other contexts (for example, when executing this manually, from the editor) this argument is not passed.

Therefore, this function is supposed to get executed automatically when users submit the form. Don't try to execute it manually from the editor, if you are using e inside the function.

No recipient:

Failed to send email: no recipient

This means emailTo is not defined, which means getRespondentEmail() is not returning anything.

This could happen for two reasons:

  • Either a form response was created by the script, but not submitted. Since this is getting executed via a form submission trigger, though, it's not your case.
  • The other reason, which is most likely what's going here, is that you didn't enable the option to collect the email addresses. You can do that programmatically, by calling Form.setCollectEmail(collect), or through the UI, by following the guide in Collect respondents' email addresses.

Related:

  • How can I test a trigger function in GAS?
  • Event Objects
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda