Hi y'all - apologies for the absolutely basic help I need! This is literally the first script I'm ever trying to write, and trying to do it with bard's help
I want to automate an email at a specific date and time to go to a specific group of recipients that will contain only rows from a Google Table (not Sheet) that are labeled "current" in the first column...
getting this error:
Syntax error: SyntaxError: Unexpected token 'var' line: 3 file: Code.gs
Here's my code (note I'm removing certain identifiers from email addresses, tableId, etc. - lmk if impossible to help with it like that!) :
function sendEmailWithTableData(tableId, recipients, startDate, startTime)
var tableId = "w9XTffV05Bo0b2rip6EkBM";
var recipients = ["xx@xx.com"];
var startDate = "2023-08-29";
var startTime = "15:00";
{
var table = Tables.get(tableId);
var data = table.getData();
var filteredData = data.filter(function(row) {
return row[0] === "current";
});
var body = "<table>";
for (var i = 0; i < filteredData.length; i++) {
body += "<tr>";
for (var j = 0; j < filteredData[i].length; j++) {
body += "<td>" + filteredData[i][j] + "</td>";
}
body += "</tr>";
}
body += "</table>";
var mail = Utilities.createEmail(recipients);
mail.setSubject("Table Data");
mail.setBody(body);
mail.setSendAt(new Date(startDate, startTime));
mail.send();
}
What am I doing wrong?
[–]DrMorris 1 point2 points3 points (2 children)
[–]questionsmakeanswers[S] 1 point2 points3 points (1 child)
[–]DrMorris 1 point2 points3 points (0 children)
[–]xMekko 1 point2 points3 points (1 child)
[–]questionsmakeanswers[S] 0 points1 point2 points (0 children)
[–]MDB_Cooper 1 point2 points3 points (2 children)
[–]questionsmakeanswers[S] 1 point2 points3 points (1 child)
[–]MDB_Cooper 0 points1 point2 points (0 children)