小编Bra*_*don的帖子

如何使用 Google Apps 脚本将 HTML 代码从 .gs 插入 HTML 文件

我使用下面的代码将变量插入到 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为代码?

html google-apps google-apps-script

2
推荐指数
1
解决办法
2861
查看次数

标签 统计

google-apps ×1

google-apps-script ×1

html ×1