I´m trying to create an HTML table which get´s data from an array that is being passed from request.gs to template.html.
My current setup is:
request.gs (partial snippet):
var products = tempSheet.getRange("B2:B").getValues();
var template = HtmlService.createTemplateFromFile('template');
template.products = products;
var emailToSend = template.evaluate().getContent();
MailApp.sendEmail({
to: Session.getActiveUser().getEmail(),
subject: 'test mail ' + Utilities.formatDate(new Date(), "GMT+2", "dd.MM.yyyy"),
htmlBody: emailToSend
});
template.html (partial snippet):
<table>
<tr>
<th>Product Name</th>
</tr>
<tr>
<td>placeholder</td>
</tr>
</table>
I do have access to the products variable within the template.html using <?= products ?>.
Where my current knowledge and tries ended so far is how to add table rows and the data of products in each of the rows.