Brenda Harrison
Brenda Harrison

Reputation: 29

Error Message: function doGet for Google App Script to HTML

I'm trying to create a html wep app from google script. I started by getting an error message for no doGet Function. Now I'm getting a new error ....Exception: No HTML file named messages was found. (line 21, file "Code")

Can I please get an example of what a doGet function should look like so I can move on with life. Nothing I have read shows where to put it how to use it. Should it be at the beginning and the end in the middle. Come on, can I get some answers in plain english please.

Here is the code i've used:

function getRelevantMessages()
{
  var threads = GmailApp.search("from:[email protected] AND subject: Fwd: New submission 
from Find Me the Perfert Home",0,10);
  var messages=[];
  threads.forEach(function(thread)
              {
                messages.push(thread.getMessages()[0]);
              });
  return messages;
}


function getMessagesDisplay()
{
  var templ = HtmlService.createTemplateFromFile('messages');
  templ.messages = getRelevantMessages();
  return templ.evaluate();  
}
function doGet(e) {
  return HtmlService
    .createTemplateFromFile('messages.html')//This is html file we want to render
    .setTitle("messages");//We can set title from here
}




 

Upvotes: 0

Views: 694

Answers (1)

Cooper
Cooper

Reputation: 64140

Try

function doGet(e) {
  return HtmlService
    .createTemplateFromFile('messages')//This is html file we want to render
    .setTitle("messages");//We can set title from here
}

Upvotes: 1

Related Questions