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
Yaswanth KothapalliYaswanth Kothapalli 

Email Notification When the Scheduled Job End date is Approaching

Hi ,

Can anyone help me in sample code for the following scenario like:
- When ever the Scheduled jobs end date is approaching, an email notification should be fired to the User  and
- What is the best practice to be followed for nearing end date for a job?

NOTE: I understand that through the normal UI, there is no way for the same. Infact we can create logic using Message.SingleEmail method in the class that implements Database.Batchable<:sObject>. 
Following this link for referenec: 

I was trying the sample code. However Any other ideas would be more helpful to achieve this. 

Thanku All 

Ajay K DubediAjay K Dubedi
Hi Yaswanth,

You can write a trigger for your requirement and get the scheduled jobs details using the SOQL from crontriggers as described in the below link.
get the results from the query and check the end dates and accordingly send the email using the messaging class .