如何使用 App 脚本在 Gmail 插件中使用 HtmlService

Shu*_*pta 5 google-apps-script gmail-addons

我正在创建一个 Gmail 插件。以下参考页面显示 - https://developers.google.com/gmail/add-ons/reference/

“Gmail 插件是使用 Apps 脚本及其提供的许多服务构建的。构建插件时,您可以使用任何 Apps 脚本服务”

基本上,我希望在单击 Gmail 插件中的按钮时弹出小屏幕。

截至目前,我已在我的部分中添加了一个按钮,如下所示,并将其绑定到操作处理程序“htmltest”:-

var htmlTest = CardService.newAction().setFunctionName('htmlTest');
var button = CardService.newTextButton().setText("htmlTest").setOnClickAction(htmlTest);
section.addWidget(button);
Run Code Online (Sandbox Code Playgroud)

这就是 htmlTest 的样子:-

function htmlTest(e){
return HtmlService.createHtmlOutputFromFile('doubleCheck');
}
Run Code Online (Sandbox Code Playgroud)

这是我希望弹出的 doubleCheck.html 文件:-

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    Hello, World!
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

但是当我单击该按钮时,它会出现运行时错误:- 标记中缺少必填字段:

创建 Gmail 时如何使用 HtmlService 的任何线索

Ron*_*den 2

在 CardService 的概述部分,它引用了:

\n\n

\xe2\x80\x9c目前您只能使用此服务来构建 Gmail 插件。\xe2\x80\x9c

\n\n

因此目前构建 Gmail addon\xe2\x80\x99s 时 HtmlService 不可用。

\n\n

https://developers.google.com/apps-script/reference/card-service/

\n