title: How to use template engines to send text as email in nodejs
body: <p>MsSql - 2014</p>
  
  <p>I recently started programming on nodeJs.</p>
  
  <p>I have email template in data base tabel. </p>
  
  <p>For eg: </p>
  
  <pre><code>   message1 : Hello {friendName},
                    Happy Birthday {friendName}.
                    Thank you,
                    {Name}
  
      message2 : Hello All,
                    The total expense as;
                      {ListOfExpense}
                    Thank you,
                    {Name}
  </code></pre>
  
  <p>For message 1 -- I have UI input as name and friendName on input obj.
  For message 2 -- I have UI input of List of expense on input.expense obj.</p>
  
  <p>I am able to read from DB let say in var dbMessage = message 1 or message 2;</p>
  
  <p>I want to use template engines to change {} values according to template and store on the text so I can set on the body.</p>
  
  <p>I am using nodemailer to send mail;</p>
  
  <pre><code>var mailOptions={
          to : req.query.to,
          subject : req.query.subject,
          text : ? // I want use text as email body.
      }
  
      smtpTransport.sendMail(mailOptions, function(error, response){
          if(error){
             res.end("error");
          }else{
             res.end("sent");
          }
      });
  </code></pre>
  
  <p>Kindly help.</p>