"createHtmlOutputFromFile" 的输出非常直白,没有使用我编写的代码
The output for "createHtmlOutputFromFile" is very literal and not utilizing the code I wrote
所以我写了一个脚本,其中有一个 HTML 文件与之关联。脚本很长所以我不会 post 它,但最后我有这个:
// Send HTML content in email
var htmlBody = HtmlService.createHtmlOutputFromFile("AttendanceInfractionsHTMLTemplate").getContent();
MailApp.sendEmail({
to: Session.getActiveUser().getEmail(),
subject: 'EI Email',
htmlBody: htmlBody,
});
}
问题是,当我在收件箱中收到电子邮件时,HTML 模板中的代码没有 运行 成功,它显示了 scriptlet 的所有荣耀,比如我的if/else 语句等等。当我部署 HTML 文件的测试时,不会发生这种情况。有任何想法吗?在 Google Apps 脚本参考指南中似乎找不到任何相关信息。
您需要使用createTemplateFromFile()
and evaluate()
它:
var htmlBody = HtmlService.createTemplateFromFile("AttendanceInfractionsHTMLTemplate")
.evaluate()
.getContent()
所以我写了一个脚本,其中有一个 HTML 文件与之关联。脚本很长所以我不会 post 它,但最后我有这个:
// Send HTML content in email
var htmlBody = HtmlService.createHtmlOutputFromFile("AttendanceInfractionsHTMLTemplate").getContent();
MailApp.sendEmail({
to: Session.getActiveUser().getEmail(),
subject: 'EI Email',
htmlBody: htmlBody,
});
}
问题是,当我在收件箱中收到电子邮件时,HTML 模板中的代码没有 运行 成功,它显示了 scriptlet 的所有荣耀,比如我的if/else 语句等等。当我部署 HTML 文件的测试时,不会发生这种情况。有任何想法吗?在 Google Apps 脚本参考指南中似乎找不到任何相关信息。
您需要使用createTemplateFromFile()
and evaluate()
它:
var htmlBody = HtmlService.createTemplateFromFile("AttendanceInfractionsHTMLTemplate")
.evaluate()
.getContent()