I am trying out a code where I get a mail with specific subject line - "Your daily habit tracker"+previous day's date;
While I figured out how to publish today's date - I am just not able to understand how I can publish yesterday's date instead. Attaching code, please help thank you!
var now = Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "dd-MMMM");
function sendFormEmail() {
var toEmailAddress = "1@mailinator.com";
var now = Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "dd-MMMM");
var htmlMessage = HtmlService.createHtmlOutputFromFile("Habit tracker form.html").getContent();
var subject = "Daily keystone habit tracker";
var message = "Some message";
Logger.log(now);
// MailApp.sendEmail(toEmailAddress, subject, message, {
// name: 'Future Mac',
// htmlBody: htmlMessage
// });
}
let Yesterday = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() -1);