mk_yo
mk_yo

Reputation: 780

display gmail message in google app script gui

What is the best way to display content of gmail message in google apps script web app? Here's example of my message raw html:

message.getBody();

<div><em><strong><u>TEST</u></strong></em></div>

so the question actually is how to show that raw html in some window or pop-up

Upvotes: 0

Views: 444

Answers (1)

HDCerberus
HDCerberus

Reputation: 2143

I think what your looking for is the HTML Output class which allows you to create basic HTML files in Apps script.

A script such as:

function myFunction() {
var threads = GmailApp.getInboxThreads();
var messages = threads[0].getMessages()[0];
var raw = messages.getPlainBody();
return raw;
}

function doGet() {
   var raw = myFunction();
   return HtmlService.createHtmlOutput('<b><p>'+ raw + '</p></b>');
 }

Will allow you to create a HTML file that has the content of the users last email message whenever they visit the deployed page.

My sample above is very basic, but you can tidy it up to display what you want.

Upvotes: 1

Related Questions