我们正在使用Google Apps Script构建一个Gmail插件。我们遇到了一个奇怪的问题,Apps Script在编写的电子邮件中插入了两次HTML。这是在电子邮件中插入两次“HELLO”的示例代码:
function insertHtml(e) {
var html = "<span>HELLO</span>"
var response = CardService.newUpdateDraftActionResponseBuilder()
.setUpdateDraftBodyAction(CardService.newUpdateDraftBodyAction()
.addUpdateContent(html, CardService.ContentType.IMMUTABLE_HTML)
.setUpdateType(CardService.UpdateDraftBodyType.IN_PLACE_INSERT))
.build();
return response;
}
奇怪的是,如果你放一个
style
上
<span>
function insertHtml(e) {
var html = "<span style=\"color: red;\">HELLO</span>"
var response = CardService.newUpdateDraftActionResponseBuilder()
.setUpdateDraftBodyAction(CardService.newUpdateDraftBodyAction()
.addUpdateContent(html, CardService.ContentType.IMMUTABLE_HTML)
.setUpdateType(CardService.UpdateDraftBodyType.IN_PLACE_INSERT))
.build();
return response;
}
如果你使用它,它也会起作用
ContentType.MUTABLE_HTML
.
这看起来像是插件中的一个bug。我们无法确保插入的HTML不包含
<
那么,我们如何使用
IMMUTABLE_HTML
?