I'm working on standalone web app using Google apps script based on html template. The purpose of the app is kind of a simple gmail but with custom filter. I'v already done that filter and show the list of emails but got stuck on the problem with rendering html body of a message.
Here's the part of code:
Html template:
<table id="myTable">
</table>
<script>
...
for (var i = 0; i < threads.length; i++)
{
var row = table.insertRow(0);
row.setAttribute("messageId", threads[i].id);
row.onclick = (function() {
google.script.run.openMessage(this.getAttribute("messageId"));
});
var cell1 = row.insertCell(0);
cell1.innerHTML = threads[i].subject;
}
...
</script>
Google script:
function doGet() {
return HtmlService
.createTemplateFromFile('index')
.evaluate().setSandboxMode(HtmlService.SandboxMode.NATIVE);
}
...
function openMessage(id)
{
var message = GmailApp.getMessageById(id);
var body = HtmlService.createHtmlOutput(message.getBody());
}
...
The question is: What are the best way to show the message body on click? When I try to open it in new window (window.open()...
)b it trows an error, modal window isn't working from html template as well.
Thanks in advance for any help!