'I'd like to send a reminder using Google's Apps Script, that pulls different data depending on the actual month of the year
I have a calendar that is set up in Google Sheets with information that is displayed in a table like such;
July Week System Activity Notes Status Jul-4 Week 1
Each table is a named range for each month. I have reminder that will be emailed to me but I want the data to changed depending on the month, without me having to go in and manually changing the range listed in the script. Here is my script.
function sendMayChecklist() {
var sheet = SpreadsheetApp.getActiveSheet();
var date = Utilities.formatDate(new Date(), "PST", "MM/dd/yyyy")
var subject = "Daily Update for " + date;
var recipiants = "[email protected]";
var data = sheet.getRange('May').getValues();
var email_body = '<html><body> Hey Byro <br> <br> Please see your daily checklist below: <br> <br> <table style = border-collapse:collapse; border = 1 cellpadding = 5><tr>';
for (var row=0;row<data.length;++row){
for (var col = 0; col<data[0].length;++col)
{
if (row==0)
{email_body+='<th>'+data[row][col]+'</th>'}
else{
email_body+='<td>'+data[row][col]+'</td>'
}
}
email_body+='</tr><tr>'
}
email_body += '</tr></table><br><br> Thank You </body></html>'
MailApp.sendEmail(recipiants,subject,"",{htmlBody:email_body})
}
Solution 1:[1]
Try this:
var data = sheet.getRange(Utilities.formatDate(new Date(),Session.getScriptTimeZone(),"MMM")).getValues();
Solution 2:[2]
I see no serilog.log.error, only this.logger.Error.
You ask why you dont see DbName and Client in log, if I read you correctly. It is because you don't log it. You log the exception, which can be anything, and the name of the method.
Maybe something like `this.logger.Error(ex, $"{nameof(LoggingEnrichmentMiddleware)} caught exception. DBName={txtDBName},UserName={txtUserName}");
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Cooper |
| Solution 2 | LosManos |
