Search code examples
google-apps-scriptgmailgmail-api

apps script getBody doesn't give full html contents


I get emails from a system that contains paragraphs and tables.

When I try to get full html format using getBody from email it gives me just CSS contents and not the whole html contents. This is 'inspect element' of email that doesn't work. Just CSS with no HTML contents.

However when I copy full email body and send it to myself in a new email then getBody function gives me accurately full body in html format including all tags and contents. This is 'inspect element' of email that works. Correct Html data

Kindly guide what I am missing here?

var label = GmailApp.getUserLabelByName("INBOX/reports0");
var threads = label.getThreads();
var tempbody = threads[i].getMessages()[0].getBody();

Regards


Solution

  • As the logged output in the console is too large and it's being truncated you're not seeing the whole output in neither of the cases, you're getting the entire HTML you just don't see it there. You can use Stackdriver logging instead to show the whole output.