Daily report to email
3 posts by 3 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: October 31, 2016 (RSS)
By Toledoh - October 18, 2016
Hi Guys,
No rush on this one - just hoping to get some direction.
I want to create a plugin that runs daily, and sends an email to a chef on how many booking / meals etc there are for the kitchen the next day.
I've got a report viewable via a URL that lists each booking for the queried date range, then totals the numbers at the end. I want to send those total in an email.
How would I go about setting that up?
Tim (toledoh.com.au)
By ross - October 31, 2016
Hi Tim
What I would do is setup a custom script using the cron system in CMS Builder. The script can be scheduled to run once a day.
The first step is to take the script you already created and add the email components to it.
This will involve setting up an email template and then using the function sendMessage().
Are you familiar with our sendMessage() function and how to have it use an email template?
After that, we can look at how to have this script run automatically via cron.
Does that all make sense?
Let me know any questions.
Thanks.
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com
Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/
By Dave - October 31, 2016
Hi All,
Tim had us build a simple script for him to do this and said we could post it here in case it was helpful to anyone else.
I've attached a plugin "Automated Email Report" which sends out an email at 3am nightly.
It has links in the plugin menu to "Preview Email", to show what would be sent, and "Send Now" to send a test message immediately.
How it works is it takes the content returned by the aem_previewEmail() function and emails it. So in that function you can require another PHP file with a viewer, add some getRecords code, or whatever you need.
You can customize the time it sends out the email with this line (which has instructions above it):
addCronJob('aem_sendNow', "Automated Email Report", '0 3 * * *'); // Run at 3am every day
You can customize the from/to/subject with these lines:
'from' => "user@example.com",
'to' => "user@example.com",
'subject' => "Daily Report",
And you can customize the contents of the email by adding code to aem_previewEmail();
Hope that helps!
interactivetools.com