I'm trying to implement a create HTML table based on rows then email script, so far that part is working, the problem comes when I try to only send certain rows to the table that is then sent
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var ws = ss.getSheetByName('2021')//rename sheet name per your file;
var headers = ws.getRange('A1:H1').getDisplayValues()//get table headers name;
//assign variable to each header value
var name = headers[0][0];
var leavetype = headers[0][1];
var fromDate = headers[0][2];
var toDate = headers[0][3];
var totaldays = headers[0][4];
var status = headers[0][5];
var reportingmanager = headers[0][6];
var checksum = headers[0][8];;
const lr = ws.getRange('B1').getValues()
var tablerangeValue = ws.getRange(2,1,10,8).getDisplayValues()//get range value, my data range start from 4th row and has 7 columns, pls chage per your need;
if (checksum == 2);
var htmlTemplate = HtmlService.createTemplateFromFile('emailTable');
htmlTemplate.name = name;
htmlTemplate.leavetype = leavetype;
htmlTemplate.fromDate = fromDate;
htmlTemplate.toDate = toDate;
htmlTemplate.totaldays = totaldays;
htmlTemplate.status = status;
htmlTemplate.reportingmanager = reportingmanager;
htmlTemplate.tablerangeValue = tablerangeValue;
var htmlForEmail = htmlTemplate.evaluate().getContent();
var toEmail = 'jonathon.banks@westal.com.au';
var ccEmail = 'jbjono4@gmail.com';
MailApp.sendEmail({
to: toEmail,
cc: ccEmail,
subject: "Flyscreens Overdue",
htmlBody:htmlForEmail
});
}
this is the HTML that I'm currently using
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<style>
table, th, td {
border: 0px solid black;
font-size:15px;
}
th, thead {
background-color: lightblue;
}
</style>
</head>
<body>
<div>
<table>
<thead>
<th><?= name ?></th><th><?= leavetype ?></th><th><?= fromDate ?></th><th><?= toDate ?></th><th><?= totaldays ?></th><th><?= status ?></th><th><?= reportingmanager ?></th>
</thead>
<tbody >
<? tablerangeValue.forEach(r => {?>
<tr>
<td><?= r[0] ?></td><td><?= r[1] ?></td><td><?= r[2] ?></td><td><?= r[3] ?></td><td style="text-align:center"><?= r[4] ?></td><td><?= r[5] ?></td><td><?= r[6] ?></td>
</tr>
<?})?>
</tbody>
</table>
</div>
</body>
</html>
like I said so far if grabs all of the rows and places it into the table but I only want certain rows to be put into the table
I have an IF function in the sheet that generates a 1 when an email should be sent or a 2 when it shouldn't, this is based on the due date in the row, if the date is earlier then today then it generates a 1 if the due date is later then today then it generates a 2
any help would be great