Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

286
Views
Escribí un código para enviar 1 correo electrónico general y 1 correo electrónico condicional, pero el correo electrónico condicional no se envía

Quiero enviar 1 correo electrónico general y 1 correo electrónico condicional (según si la respuesta a una pregunta en particular fue 'sí' o 'no') al enviar el formulario. No tengo problemas con el envío del correo electrónico general, pero cuando selecciono la opción 'sí' en el Formulario de Google, el correo electrónico condicional no se envía. Aquí está el código que tengo hasta ahora (y también configuré los disparadores relevantes para sendEmail y sendConditionalEmail). ¡Cualquier consejo es apreciado!

 function sendEmail(e) { var html = HtmlService.createTemplateFromFile("GeneralEmail.html"); var htmlText = html.evaluate().getContent(); var emailTo = e.response.getRespondentEmail(); Logger.log(emailTo); var subjectofEmail = "TESTING INFORMATION (BRJ)"; var textBody = "This email requires HTML support"; var options = {htmlBody: htmlText}; if(emailTo !== undefined){ MailApp.sendEmail(emailTo, subjectofEmail, textBody, options); } } function sendConditionalEmail(e){ var Conditionalhtml = HtmlService.createTemplateFromFile("ConditionalEmail.html"); var ConditionalhtmlText = Conditionalhtml.evaluate().getContent(); var subjectOfEmail = "Guided Testing (BRJ)"; var textBody = "This email requires HTML support"; var interested = objectifyingFormforInterested(); var emailTo = e.response.getRespondentEmail(); Logger.log(interested); if (interested == "Yes") { MailApp.sendEmail( emailTo, subjectOfEmail,'', { htmlBody: ConditionalhtmlText, cc: 'xxx@gmail.com'}); } } function objectifyingFormforInterested(myForm){ var myForm = FormApp.openById("13o_WK3G8m6PeopBrI2y6p6SrNp-cGFs3vgpRdqotISY"); var formResponses = myForm.getResponses(); Logger.log(formResponses); var currentResponse = formResponses[formResponses.length-1]; var responseArray = currentResponse.getItemResponses(); Logger.log(responseArray); var form= {}; form.user = currentResponse.getRespondentEmail(); form.timestamp = currentResponse.getTimestamp(); form.formName = myForm.getTitle(); var response = responseArray[responseArray.length-1].getResponse(); Logger.log(response); return response; } function camelize(str) { str = str.replace(/[\.,-\/#!$%\^&\*;:{}=\-_`~()@\+\?><\[\]\+]/g, '') return str.replace(/(?:^\w|[AZ]|\b\w|\s+)/g, function(match, index) { if (+match === 0) return ""; // or if (/\s+/.test(match)) for white spaces return index == 0 ? match.toLowerCase() : match.toUpperCase(); }); }
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Dirija los comentarios a continuación y tal vez pueda hacer que funcione correctamente

 function sendConditionalEmail(e) { var Conditionalhtml = HtmlService.createTemplateFromFile("ConditionalEmail.html"); var ConditionalhtmlText = Conditionalhtml.evaluate().getContent(); var subjectOfEmail = "Guided Testing (BRJ)" var interested = objectifyingFormforInterested();//You are not passing the MyForm parameter to this function var emailTo = e.response.getRespondentEmail(); if (interested == "Yes") { MailApp.sendEmail(emailTo, subjectOfEmail, null, { htmlBody: ConditionalhtmlText, cc: 'xxx@gmail.com' }); } } function objectifyingFormforInterested(myForm) { var myForm = FormApp.openById("13o_WK3G8m6PeopBrI2y6p6SrNp-cGFs3vgpRdqotISY"); var formResponses = myForm.getResponses(); var currentResponse = formResponses[formResponses.length - 1]; var responseArray = currentResponse.getItemResponses(); var form = {}; form.user = currentResponse.getRespondentEmail(); form.timestamp = currentResponse.getTimestamp(); form.formName = myForm.getTitle(); var response = responseArray[responseArray.length - 1].getResponse(); return response; }
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!