function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michael Andrews 5Michael Andrews 5 

Email list of accounts every X days

We have a catagory of accounts that need to receive an email every 10 days until a checkmark is removed from thier account. I tried using a workflow that triggered the email and delayed the next email. This worked but I ran into a limit on the number of delayed workflow jobs available.

I was thinking of switching this task to something like an Apex Schedualed class that would check for the account bit and send the email. Is this the best way to handle this?

My sudo code would be something like this:
  • (run every day)
  • query for list of accounts that have not received an email in more than 9 days.
  • update the record with something that would trigger an email
  • the tiggered email would update the date of last email

 
JSingh9JSingh9
Hi Michael
  • Create One Field Which can capture Last Date on which Email was Sent
  • Create one Field which can be set to true when need to considered for email
  • Create one Formula Field which will be true when Email was sent 10 days back AND Check box for sending email is true
  • Create Batch class and Query only those fields where formula field is true this will reduce the burden on batch in terms of how many records u can query
  • Update Date and send email through the batch only, trigger be extra work i think u can manage it within the same batch job.
  • Then finally u can have a schedule class
Let me know if u further need details
Michael Andrews 5Michael Andrews 5
After doing some research into the Apex Batch classes it appears that I do not need that. It looks like I can simply use the mass email class under Messaging. There is almost no limit to sending outbound email (I am only in the 100 records range anyway).

Thank you JSign9 for the reply the batch class is interesting but mass email looks like a better fit.