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

194
Views
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
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!