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
Rizwan Ali 8Rizwan Ali 8 

how to track Quote status and send reminder email?

Scenario is: If Quote status exceeds 7 days, send email reminder to record owner to follow up with quote

i want to do this with Apex Class
Raj VakatiRaj Vakati
You need to use apex scheduler and send email from there  .. But my opinion time base workflow is the best fit for this 

Sample code and modify the class SOQL where condition etc

 
global class SchReminderQuote implements Schedulable  {

global void execute(SchedulableContext ctx) {

    List<Messaging.SingleEmailMessage> listmail = new List<Messaging.SingleEmailMessage>();

    EmailTemplate et = [SELECT Id, Subject, HtmlValue FROM EmailTemplate WHERE developerName  = 'ET_Case_Reminder_Testing'];

    String subject = 'Testing Reminder';                            
    String htmlBody = et.HtmlValue;
    Date MyDate = Date.Today();       

    List<Quote> listQ = [SELECT Id, Status,Owner.Name, Owner.Email, Status
                        FROM Quote WHERE <ADD_CONDITION HERE TO CHECK LAST 7 Days >];


    for (Quote cs : listQ){
           
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setSubject(subject);
            mail.setHtmlBody(htmlBody); 
            mail.setTargetObjectId(cs.OwnerId);
            mail.setSaveAsActivity(false);
            listmail.add(mail);




            }

            Messaging.sendEmail(listmail);
}
}

 
Rizwan Ali 8Rizwan Ali 8
Thanks alot 
I will Check it