I am a bit stuck and can't figure why I'm getting this syntax error.
I have created a script that creates an email with the content I input into a google sheet that takes a template from an HTML file I made and it works beautifully.
However, now that I want to move the sheet to a more communal sheet for other users to operate I just get a syntax error. I've copied the sheet to the accurate cells in the new sheet and I've copied both the .gs and .html code line for line and updated the Sheet ID and sheet name and I have no idea how to fix it.
I'm suspecting that this has something to do with my.html not matching but I've doublechecked this and even changed the file names just to be sure but can't seem to troubleshoot the problem.
Hoping for some input from anyone could shed some light on my predicament.
Here is the full code:
function EODemail2() {
const ss=SpreadsheetApp.openById('xxxxxxxxxxxxxxxxxxxx');
const sh=ss.getSheetByName('Sheet 1');
const lr= sh.getLastRow()
const emailAddress = sh.getRange(2,4).getValue();
const dearAll = sh.getRange(2,2).getDisplayValue();
const message = sh.getRange(3,2).getDisplayValue();
const subscriptions= sh.getRange(4,2).getValue();
const subscriptionsNumbers=sh.getRange(6,3,2,4).getValues();
const subsComments=sh.getRange(6,2).getValues();
const operations= sh.getRange(8,2).getValue();
const weLognumbers=sh.getRange(9,2,6,4).getValues();
const operationsreport= sh.getRange(16,2).getValue();
const customerService=sh.getRange(18,2).getValue();
const csdata = sh.getRange(19,2,5,3).getDisplayValues();
const csSubs= sh.getRange(25,2).getValue();
const replacementRequests= sh.getRange(26,2).getValue();
const replacmentDataTable=sh.getRange(27,3,8,9).getValues();
const lastComents = sh.getRange(37,2).getDisplayValue();
const endParagraph = sh.getRange(39,2).getDisplayValue();
const name = sh.getRange(41,2).getDisplayValue();
const htmlTemplate = HtmlService.createTemplateFromFile('email');
htmlTemplate.dearAll = dearAll;
htmlTemplate.message = message;
htmlTemplate.subscriptions = subscriptions;
htmlTemplate.subscriptionsNumbers = subscriptionsNumbers;
htmlTemplate.subsComments = subsComments;
htmlTemplate.operations = operations;
htmlTemplate.operationsreport = operationsreport;
htmlTemplate.customerService = customerService;
htmlTemplate.weLognumbers = weLognumbers;
htmlTemplate.csdata = csdata;
htmlTemplate.csSubs = csSubs;
htmlTemplate.replacementRequests = replacementRequests;
htmlTemplate.replacmentDataTable = replacmentDataTable;
htmlTemplate.lastComents = lastComents;
htmlTemplate.endParagraph = endParagraph;
htmlTemplate.name = name;
const htmlForEmail=htmlTemplate.evaluate().getContent();
console.log(htmlForEmail);
const date = Utilities.formatDate(new Date(), "GMT+0", "dd/MM/yyyy")
const emailBody = "Hi "+date+"\n \n"+customerService;
const subject= "EOD for "+date
Utilities.sleep(10000)
Logger.log(emailAddress)
GmailApp.sendEmail(emailAddress, subject, dearAll,{ htmlBody: htmlForEmail } );
}
Here is my .HTML template I know it's simple but it's just a report so please excuse its simplicity and excuse how I've structured my HTML code, I'm not too experienced with this.
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<div>
<div>
</div>
<p><?=dearAll1?></p>
<p><?=message1?></p>
<div style= "font-weight:bold"; ><?=subscriptions1?></div>
<br>
<table style="border-spacing:0px; border-collapse: collapse">
<tbody>
<?subscriptionsNumbers1.forEach(r=>{?>
<tr>
<th style= "font-weight:normal; text-align:left; padding:7px; border:1px solid black;"><?= r[0] ?></th><th style= "font-weight:normal; text-align:left; padding:7px; border:1px solid black;"><?= r[1] ?></th>
</tr>
<?})?>
</tbody>
</table>
<p><?=subsComments1?><p/>
<br>
<div> </div>
<p style= "font-weight:bold";> <?=operations?> </p>
<table style="border-spacing:0px; border-collapse: collapse">
<tbody>
<?weLognumbers.forEach(r=>{?>
<tr>
<th style= "font-weight:normal; text-align:left; padding:7px; border:1px solid black;"><?= r[0] ?></th><th style= "font-weight:normal; text-align:left; padding:7px; border:1px solid black;"><?= r[1] ?></th><th style= "font-weight:normal; text-align:left; padding:7px; border:1px solid black;"><?= r[2] ?></th>
</tr>
<?})?>
</tbody>
</table>
<div> </div>
<p> <?=operationsreport?> </p>
<div> </div>
<p style= "font-weight:bold";> <?=customerService?></p>
<table style="border-spacing:0px; border-collapse: collapse">
<tbody>
<?csdata.forEach(n=>{?>
<tr>
<th style= "font-weight:normal; text-align:left; padding:7px; border:1px solid black;"><?= n[0] ?></th><th style= "font-weight:normal; border:1px solid black; padding:7px;"><?= n[1] ?></th>
</tr>
<?})?>
</tbody>
</table>
<div> </div>
<p style= "font-weight:bold";> <?=csSubs?></p>
<p> <?=replacementRequests?></p>
<table style="border-spacing:0px; border-collapse: collapse">
<tbody>
<?replacmentDataTable.forEach(n=>{?>
<tr>
<th style= "font-weight:normal; border:1px solid black; padding:5px;"><?= n[0] ?></th><th style= "text-align:left; font-weight:normal; border:1px solid black; padding:5px;"><?= n[1] ?></th><th style= "font-weight:normal; border:1px solid black; padding:5px;"><?= n[2] ?></th><th style= "font-weight:normal; border:1px solid black; padding:5px;"><?= n[3] ?></th><th style= "font-weight:normal; border:1px solid black; padding:5px;"><?= n[4] ?></th><th style= "font-weight:normal; border:1px solid black; padding:5px;"><?= n[5] ?></th><th style= "font-weight:normal; border:1px solid black; padding:5px;"><?= n[6] ?></th>
</tr>
<?})?>
</tbody>
</table>
<p><?=lastComents?><p/>
<br>
<p><?=endParagraph?></p>
<p><?=name?></p>
</div>
</body>
</html>