google script use html service in gmail addon

后端 未结 1 1903
醉梦人生
醉梦人生 2021-02-11 09:28

I\'ve try to create simple form in gmail addon,

how to use html service

The below code,i have tried,

function buildAddOn(e) {
  var accessToken =         


        
1条回答
  •  [愿得一人]
    2021-02-11 09:54

    I understood that you want to use HTML at Gmail add-on. If my understanding is correct, how about these sample scripts?

    Sample script 1 :

    function buildAddOn() {
      var html = HtmlService.createTemplate('Hello, world!').evaluate().getContent();
      return CardService.newCardBuilder()
      .setHeader(CardService.newCardHeader().setTitle('sample'))
      .addSection(CardService.newCardSection().addWidget(CardService.newKeyValue().setContent(html)))
      .build();
    }
    

    Sample script 2 :

    Code.gs
    function buildAddOn() {
      var html = HtmlService.createTemplateFromFile("index").evaluate().getContent();
      return CardService.newCardBuilder()
      .setHeader(CardService.newCardHeader().setTitle('sample'))
      .addSection(CardService.newCardSection().addWidget(CardService.newKeyValue().setContent(html)))
      .build();
    }
    
    index.html
    Hello, world!
    

    Result :

    Note :

    • As a sample, Manifests was used from Quickstart.
    • This is a very simple script. So please modify it for your environment.

    If I misunderstand your question, I'm sorry.

    0 讨论(0)
提交回复
热议问题