So, I've been looking through StackOverlow for a while now, and the closest answer I found is this.
I have built a template for sending emails and I'd like to reuse it for other purposes, such as the description of an event. I'm struggling to get a printout of the HTML template in a readable format, exactly as you get it in the email.
Here's the HTML template:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<p>Hi <?!= OOOCLIENTFIRSTNAME?>,</p>
</body>
</html>
Here's the template code:
var emailtemplate = HtmlService.createTemplateFromFile('XXXXX');
emailtemplate.OOOCLIENTFIRSTNAME = clientfirstname;
var emailbody = emailtemplate.evaluate();
So, when I place it into the sendEmail method parameter's htmlbody property, it works perfectly and email is sent as planned. Here's the GmailApp code:
GmailApp.sendEmail(clientemail, 'TEST TITLE', '',
{htmlBody: emailBody.getContent()};
I want to get the result as a simple string, such as "Hi firstname".
I have tried to use .getContent but this results in getting the HTML source code, and not its output. Any ideas?