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

Apex Class Send Email

I have two custom objects with Master-Detail relationship. I would like to send email to the records displayed in the child object using the visualforce email template. Could someone please assist? I came across to the following link but seems like its not helping me.


Whats the exact use case? If your email has to be sent to child records when you make any updates on your Master object record, you can follow the code at the below link:

You can query the child objects from the trigger using the parent ID in the SOQL filter  and get the email addresses and send email.
Thank you Sonam. I have a button on Master object record detail page. By clicking that button an email should go out to all listed in the child record and once the master record gets "approved", another email notification should go out to the same recipients. I have been trying to write an Apex class for the same.