title: Using Nodemailer and HTML - loop inside the HTML
body: <p>I'm writing a function using Nodemailer to send an email from my code,
  I designed an HTML code inside my code and I want to go through a map and sending its values.</p>
  <p>This is my function:
  I wrote inside the script tag how I want it to work, but of course, it's not working.</p>
  <pre><code>async function sendAlerts(market: any, messages: string) {
      var transporter = nodemailer.createTransport({
          service: 'gmail',
          auth: {
              user: 'mcd.nodemailer@gmail.com',
              pass: envs.emailPassword
          }
      });
  
      var mailOptions = {
          from: 'mcd.nodemailer@gmail.com',
          to: envs.alertReceivers,
          subject: `Snowflake alert - ${market}`,
          html: `&lt;div style='background-color:powderblue; text-align:center;'&gt;
                  &lt;h1&gt;Snowflake alert - ${market}&lt;/h1&gt;
                  &lt;h2&gt;:The following queries in ${market} returned results that are not 0\n&lt;/h2&gt;
                  &lt;/div&gt;
                  &lt;div id='queries'&gt;&lt;div&gt;
                  &lt;script&gt;
                  let failedQueries ='', i;
                  for (i=0; i&lt;= ${messages.length}; i++) {
                  failedQueries = failedQueries + &lt;b&gt;Alert Message: ${Object.keys(messages[i])} Query: ${Object.values(messages[i])} &lt;/b&gt;;
                  }
                  document.getElementById('queries').innerHTML = failedQueries;
                  &lt;/script&gt;
                  `
      };
  
      transporter.sendMail(mailOptions, function (error, info) {
          if (error) {
              console.log('Failed to send email due to: ' + error);
          } else {
              console.log('Email sent: ' + info.response);
          }
      });
        }
  </code></pre>