As mentioned in previous answers, the HtmlService can't be used directly in Workspace Add-ons, including Gmail Add-ons. The primary user interface should be created using the Card-based interfaces. The specific card elements that support formatted content are Widgets but they only support a small set of HTML formatting tags. Contrary as Editors Add-ons, the Card Service required for Worskapace Add-ons don't have dialogs and sidebars to show the HtmlService.HtmlOutput.
If it's is earsier for you to put the formatted text in an HTML file, then you can grab it using HtmlService.HtmlOutput.getContent(), just ensure that it only contains the supported HTML formatting tags.
However, it's posible to open links, either as a new window or as an overlay. Using the option to open a link as overlay make it possible to use the HtmlService for the content of this window / overlay.
If you want to keep all together, the Apps Script project could be deployed as an add-on and as a web application. This could be done using a single deployment or using different deployments.
Let's assume that we want to create a new deployment.
Click Deploy > New Deployment
Click Enable Deployment Types (the button with the cog wheel icon). A dropdown shows four options.

Select one of the options, Web App or Add-on, then click again Enable Deployment Types to select the other one.
Complete the input fields required in the Configuration panel.
Click Deploy.
Copy the web app URL.
I recommend to have a specific .gs file for the web app.
- Add an new .gs file and set a name.
- Add the
doGet function. It should return a HtmlService.HtmlOutput object.
The card that will open the link should include a button to open it. Example:
function myCard(){
return CardService.newCardBuilder()
.setHeader(CardService.newCardHeader()
.setTitle('ADD HERE THE CARD TITLE'))
.addSection(CardService.newCardSection()
.addWidget(CardService.newButtonSet()
.addButton(CardService.newTextButton()
.setText("ADD HERE YOUR BUTTON TEXT")
.setOpenLink(
CardService.newOpenLink()
.setUrl("ADD HERE THE WEB APP URL")
.setOpenAs(CardService.OpenAs.OVERLAY)
.setOnClose(CardService.OnClose.NOTHING)
)
)
)
.build()
}
From Widgets - Text Formatting
Text formatting
Some text-based widgets can support simple text HTML formatting. When setting the text content of these widgets, just include the corresponding HTML tags.
The supported tags and their purpose are shown in the following table:
| Format |
Example |
Rendered result |
| Bold |
"This is <b>bold</b>." |
This is bold. |
| Italics |
"This is <i>italics</i>." |
This is italics. |
| Underline |
"This is <u>underline</u>." |
This is underline. |
| Strikethrough |
"This is <s>strikethrough</s>." |
This is ~~strikethrough~~. |
| Font color |
"This is <font color=\"#FF0000\">red font</font>." |
This is red font. |
| Hyperlink |
"This is a <a href=\"https://www.google.com\">hyperlink</a>." |
This is a hyperlink. |
| Time |
"This is a time format: <time>2023-02-16 15:00</time>." |
This is a time format: 2023-02-16 15:00. |
| Newline |
"This is the first line. <br> This is a new line." |
This is the first line. This is a new line. |