我试图让我的谷歌电子表格发送电子邮件与数据从工作表,也是html格式。每当我试图运行它时,我总是得到以下错误.
错误异常:格式错误的HTML:.评估
评估
myFunction @ waiverClaim.gs:37
我找不到问题。我想问题在于第37行"const htmlForEmail =htmlTemplate.evaluate().getContent()“,但是我不知道哪里出了什么问题,希望这里有人能帮上忙!
下面是正在运行的脚本im
function myFunction() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const ws = ss.getSheetByName("Football");
const h1 = ws.getRange("A1").getValue();
const subheader = ws.getRange("A4:F4").getValues();
const priority = subheader[0][0];
const player = subheader[0][1];
const transaction = subheader[0][2];
const bid = subheader[0][3];
const years = subheader[0][4];
const dropped = subheader[0][5];
const lr = ws.getLastRow();
const tableRangeValues = ws.getRange(5,1,lr-5,6).getValues();
const totalLine = ws.getRange(lr,3,1,6).getValues();
const totalText = totalLine[0][0];
const totalSum = totalLine[0][1];
const htmlTemplate = HtmlService.createTemplateFromFile("email");
htmlTemplate.h1 = h1;
htmlTemplate.subheader = subheader;
htmlTemplate.priority = priority;
htmlTemplate.player = player;
htmlTemplate.transaction = transaction;
htmlTemplate.bid = bid;
htmlTemplate.years = years;
htmlTemplate.dropped = dropped;
htmlTemplate.totalText = totalText;
htmlTemplate.totalSum = totalSum;
htmlTemplate.tableRangeValues = tableRangeValues;
const htmlForEmail = htmlTemplate.evaluate().getContent();
console.log(htmlForEmail);
GmailApp.sendEmail(
"me@gmail.com",
"Waiver Claim Submission",
"Tom Brady $45 1 year",
{ htmlBody: htmlForEmail }
);
}以及相应的html:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<div>
<div>
<h1><?= h1 ?></h1>
</div>
<div>
<div <?= subheader ?></div>
</div>
</div>
<table>
<thead>
<tr>
<th><?= priority ?></th>
<th><?= player ?></th>
<th><?= transaction ?></th>
<th><?= bid ?></th>
<th><?= years ?></th>
<th><?= dropped ?></th>
</tr>
</thead>
<tbody>
<tr>
<td>Col D1</td>
<td>Col D2</td>
<td>Col D3</td>
<td>Col D4</td>
<td>Col D5</td>
<td>Col D6</td>
</tr>
</tbody>
<tfoot>
<tr>
<td></td>
<td></td>
<td><?= totalText ?></td>
<td><?= totalSum ?></td>
<td></td>
<td></td>
</tr>
</tfoot>
</table>
</body>
</html>如果我需要提供更多关于情况的信息,我很乐意提供。
发布于 2021-08-26 21:12:00
你错过了>在<div <?= subheader ?></div>。
试着用这个:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<div>
<div>
<h1><?= h1 ?></h1>
</div>
<div>
<div> <?= subheader ?></div>
</div>
</div>
<table>
<thead>
<tr>
<th><?= priority ?></th>
<th><?= player ?></th>
<th><?= transaction ?></th>
<th><?= bid ?></th>
<th><?= years ?></th>
<th><?= dropped ?></th>
</tr>
</thead>
<tbody>
<tr>
<td>Col D1</td>
<td>Col D2</td>
<td>Col D3</td>
<td>Col D4</td>
<td>Col D5</td>
<td>Col D6</td>
</tr>
</tbody>
<tfoot>
<tr>
<td></td>
<td></td>
<td><?= totalText ?></td>
<td><?= totalSum ?></td>
<td></td>
<td></td>
</tr>
</tfoot>
</table>
</body>
</html>https://stackoverflow.com/questions/68944050
复制相似问题