I have a managed package that users will install to their org. I want to somehow run a task daily that will build an aggregate a list of Events
created that day, format it into an email body, and send it to a list of emails (to be pulled in from an external REST API resource).
What is the best way to do this? The code I want to run daily will be an apex class that should run a simple query with a range constraint on the Event.CreatedDate
field. I can send an email in apex code with the Messaging.sendEmail()
class.
I'm not clear on how to run this code daily, and how to add this "scheduler" to the managed package. It looks like the Scheduler interface is to be scheduled from apex code, so would I schedule the first task during a post install script, and continuously schedule the next task for 24 hours later? What if the chain gets broken?
What is the best way to run this apex class every day at a set time?