And here is the sending mail code
JS reprot
Sharmishtha Chandane
Mon 3/6/2017 11:14 AM
Inbox; Sent Items
To:
Sharmishtha Chandane;
https://jsreport.net/blog/sending-reports-periodically-in-email
function toJSON(data) {
return JSON.stringify(data);
}
function beforeRender(done) {
require('request')({ url: 'http://127.0.0.1:5488/api/report/getTemplate', json:true },function(err, response, body) {
request.template.data = body;
done();
});
}
function afterRender( done) {
var SendGrid = require('sendgrid');
var sendgrid = new SendGrid('', '');
sendgrid.send({ to: 'sharmishth...@arrkgroup.com', from: 'sharmishth...@arrkgroup.com', subject: 'Sending PDF template',
html: 'This is your report',
files: [ {filename: 'Report.pdf', content: new Buffer(response.content) }]
}, function(success, message) {
done(success);
});
}
And log:
JS report log
2017-03-06T05:16:57.493Z - info: Starting rendering request 9 (user: null) requestId=9
2017-03-06T05:16:57.494Z - info: Rendering template {shortid:S1tR2CfYg, recipe:phantom-pdf,engine:handlebars} requestId=9
2017-03-06T05:16:57.494Z - debug: Data item not defined for this template. requestId=9
2017-03-06T05:16:57.495Z - debug: Executing script rJpI_05Fe requestId=9
2017-03-06T05:16:57.788Z - debug: Resources not defined for this template. requestId=9
2017-03-06T05:16:57.788Z - debug: Rendering engine handlebars requestId=9
2017-03-06T05:16:58.057Z - debug: Compiled template not found in the cache, compiling timestamp=Mon Mar 06 2017 10:46:58 GMT+0530 (India Standard Time), requestId=9
2017-03-06T05:16:58.059Z - debug: Replaced images [] requestId=9
2017-03-06T05:16:58.059Z - debug: Executing recipe phantom-pdf requestId=9
2017-03-06T05:17:02.700Z - debug: Converting in dedicated phantomjs 1.9.8 timestamp=Mon Mar 06 2017 10:46:58 GMT+0530 (India Standard Time), requestId=9
2017-03-06T05:17:02.703Z - debug: Request file:///C%3A%5CUsers%5CSHARMI~1%5CAppData%5CLocal%5CTemp%5Cjsreport-temp%5C1f0928c0-022c-11e7-9bac-1f6887691137html.html timestamp=Mon Mar 06 2017 10:46:58 GMT+0530 (India Standard Time), requestId=9
2017-03-06T05:17:02.705Z - debug: Request http://code.jquery.com/jquery-1.11.0.min.js timestamp=Mon Mar 06 2017 10:46:58 GMT+0530 (India Standard Time), requestId=9
2017-03-06T05:17:02.706Z - debug: Request http://code.highcharts.com/highcharts.js timestamp=Mon Mar 06 2017 10:46:58 GMT+0530 (India Standard Time), requestId=9
2017-03-06T05:17:02.708Z - debug: phantom-pdf recipe finished with 1 pages generated requestId=9
2017-03-06T05:17:02.710Z - debug: Skipping storing report. requestId=9
2017-03-06T05:17:02.715Z - info: Rendering request 9 finished in 5223 ms requestId=9
2017-03-06T05:18:36.323Z - debug: OData query on templates
2017-03-06T05:18:36.332Z - debug: OData query on settings
2017-03-06T05:24:54.114Z - debug: OData query on templates
2017-03-06T05:24:54.133Z - debug: OData query on settings
What I am doing here?
Thanks
Thanks
Thanks