Is it possible to add namedValues in a scriptlet when trying to use HTML template to send mails in App Script? If yes, how please, if no, how can I refer to each question on a Google form using scriptlets so that on form submission, the HTML template will evaluate() each record submitted? Below is the code
function sendEmail(e) {
var named_values = e.namedValues;
var name = named_values["Name"]
var timestamp = named_values["Timestamp"]
var subject = "Outlet "+ timestamp +""
const outlet = HtmlService.createTemplateFromFile('outlet');
outlet.named_values = named_values;
const message = outlet.evaluate().getContent();
MailApp.sendEmail({
to: '[email protected]',
subject: subject,
htmlBody: message
});
}
...and below is the template code
<!DOCTYPE html>
<html>
<body>
<ul><li><b>Company:</b> <?= name ?></li>
<li><b>Loaction:</b> <?= timestamp ?></li></ul>
</body>
</html>
I need the script to pick 'Name' and 'Timestamp' from the data submitted last from the Google form and send it to mail using the HTML template. Thanks.