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

197
Vistas
Send Mail using nodemailer html as render jade in mail - nodeJS

Im getting following error while running

Error: Failed to lookup view "index" in views directory "C:\TFS\tambola-generator-master♂iews" at Function.render (C:\TFS\tambola-generator-master\node_modules\express\lib\application.js:580:17) at ServerResponse.render (C:\TFS\tambola-generator-master\node_modules\express\lib\response.js:1017:7) at C:\TFS\tambola-generator-master\server.js:104:7 at Layer.handle [as handle_request] (C:\TFS\tambola-generator-master\node_modules\express\lib\router\layer.js:95:5)

Code

app.get('/', function (req, res) {
  var tickets = tambola.default.generateTickets(1);
  
  tickets.map(t => t._entries).forEach(element => {
    element.filter(function(e){return e});
    var smtpTransport = nodemailer.createTransport(({
      host: 'smtp.zoho.com',
         //  secureConnection: true,         // use SSL
         port: 465,
         secure:true,
         requireTLS:true,
         auth: {
           user: 'xxx',
           pass: 'ccc'
         }
 }));
    data = element;
    config = {
      columns: {
        0: {
          width: 5   // Column 0 of width 1
        },
        1: {
          width: 5  // Column 1 of width 20
        },
        2: {
          width: 5   // Column 2 of width 5
        },
        3: {
          width: 5   // Column 2 of width 5
        },
        4: {
          width: 5   // Column 2 of width 5
        },
        5: {
          width: 5   // Column 2 of width 5
        },
        6: {
          width: 5   // Column 2 of width 5
        },
        7: {
          width: 5   // Column 2 of width 5
        },
        8: {
          width: 5   // Column 2 of width 5
        }
        

      }
    }
    

    var readHTMLFile = function(path, callback) {
      fs.readFile(path, {encoding: 'utf-8'}, function (err, html) {
          if (err) {
             callback(err); 
             throw err;
              
          }
          else {
              callback(null, html);
          }
      });
  };
  
 
  
  readHTMLFile(__dirname + '/Views/index.html', function(err, html) {
      var template = jade.compile(html);
      var replacements = {
           username: "John Doe"
      };
      var htmlToSend = template(replacements);
      var mailOptions = {
          from: 'xxx',
          to: 'ccccc',
          subject : 'test subject',
          html : htmlToSend
       };
      smtpTransport.sendMail(mailOptions, function (error, response) {
          if (error) {
              console.log(error);
              callback(error);
          }
      });
  });
    
  });
  
  var sequence = tambola.default.getDrawSequence();
  res.render('index',{tickets: tickets.map(t => t._entries)});
});

about 4 years ago · Juan Pablo Isaza
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