我使用下面的代码将变量插入到 HTML 文件中,该变量以纯文本形式插入,并且不在我的变量中注册代码。
function sendEmail(){
var htmlBody = HtmlService.createTemplateFromFile('emailFormat');
var variableOne = "text";
htmlBody.example = '<p>' + variableOne + '</p>';
var email_html = htmlBody.evaluate().getContent();
MailApp.sendEmail({
to: "email@email.com",
subject: "subject",
htmlBody: email_html
});
}
Run Code Online (Sandbox Code Playgroud)
上面的代码使我<?= example ?>在文件“emailFormat”中放置的任何位置都成为"<p>text</p>". 问题是它没有将其显示为"<p>text</p>"完全显示的“文本”。如何让它显示注册<p>'s为代码?