function getGreeting() { var today = new Date() var curHr = today.getHours() if (curHr < 12) { return 'Good morning.'; } else if (curHr < 18) { return 'Good afternoon.'; } else { return 'Good evening.'; } } function constructEMailBody(_htmlTemplate, _textTemplate, _studentName, _schoolName, _editResponseURL, _folderURL) { try { /* Create email message using a template */ let htmlTemplate = HtmlService.createTemplateFromFile(_htmlTemplate); let textTemplate = HtmlService.createTemplateFromFile(_textTemplate); const greeting = getGreeting(); htmlTemplate.greeting = greeting; htmlTemplate.studentName = _studentName; htmlTemplate.schoolName = _schoolName; htmlTemplate.editResponseURL = _editResponseURL; htmlTemplate.subFolderUrl = _folderURL; textTemplate.greeting = greeting; textTemplate.studentName = _studentName; textTemplate.schoolName = _schoolName; textTemplate.editResponseURL = _editResponseURL; textTemplate.subFolderUrl = _folderURL; let htmlMessage = htmlTemplate.evaluate().getContent(); let textMessage = textTemplate.evaluate().getContent(); return [htmlMessage, textMessage]; } catch (err) { Logger.log(err); MailApp.sendEmail('wayde_johnson@dpsnc.net', 'Error in constructEMailBody', err); } } function sendEmailText(message, email, subject, messageHTML) { try { MailApp.sendEmail(email, subject, message, { replyTo: 'wayde.johnson@dpsnc.net', subject: subject, htmlBody: messageHTML }) } catch (err) { Logger.log(err); MailApp.sendEmail('wayde_johnson@dpsnc.net', 'Error in sendEMailText', err); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter