Closed amrithajayadev closed 9 years ago
I have added a trigger for scheduling mail to my script, but the trigger seems to fail. My sheet is generated by a query as below.
=Query(Sheet1!A1:E99,"Select B,C,D Where E = 'Open' Order By C,D" )
The script works fine if I run manually.Here is my script:
function ReportByMail() {
var ss= SpreadsheetApp.getActiveSpreadsheet();
var mRows = ss.getActiveSheet().getRange('F2').getValue();
var range=ss.getActiveSheet().getRange(1, 1, mRows-1, 3); var conv = SheetConverter.init(ss.getSpreadsheetTimeZone(), ss.getSpreadsheetLocale());
var html = conv.convertRange2html(range); MailApp.sendEmail("amrithajayadev@gmail.com","Daily Reminder Services","body",{htmlBody:html} ); }
A timed trigger will receive null when it calls SpreadsheetApp.getActiveSpreadsheet(), since there is no Sheets instance attached to it. Instead, you need to open the spreadsheet by URL or ID.
null
SpreadsheetApp.getActiveSpreadsheet()
I have added a trigger for scheduling mail to my script, but the trigger seems to fail. My sheet is generated by a query as below.
=Query(Sheet1!A1:E99,"Select B,C,D Where E = 'Open' Order By C,D" )
The script works fine if I run manually.Here is my script:
function ReportByMail() {
var ss= SpreadsheetApp.getActiveSpreadsheet();
var mRows = ss.getActiveSheet().getRange('F2').getValue();
var range=ss.getActiveSheet().getRange(1, 1, mRows-1, 3); var conv = SheetConverter.init(ss.getSpreadsheetTimeZone(), ss.getSpreadsheetLocale());
var html = conv.convertRange2html(range); MailApp.sendEmail("amrithajayadev@gmail.com","Daily Reminder Services","body",{htmlBody:html} ); }