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
LorrMcLorrMc 

How do I send email when date is reached with a trigger?

Hi, 
I am new to tirggers so I hope you can help, I need to send multiple email alerts based on a date field. 
The emails should send at 60,50,40,30 and 10 days before the Registration renewal date field. 
I can not use a workflow or process builder as the records will not be edited and the date may not be populated when the record is created.

I would be grateful if you could please advise as I am tottaly lost.

I hope this makes sense and Thank you in advance. 

Lorr
Aditya MohanAditya Mohan

Hi Lorr,

The best solution in this scenario would be to create a Apex batch class which can be scheduled to run on a daily basis.

In the batch class, you can write a logic to check if today's date is 60,50,40,30 or 10 days days prior to the Renewal date and send an email accordingly.

Let me know if you need any further clarification.

LorrMcLorrMc
Hi Aditya, 

Thank you for the response, how do I create a batch class?

Sorry this really is new to me.
Lorr