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
UrvikUrvik 

Apex Class Send Email

Hi,
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.

https://www.salesforce.com/us/developer/docs/pages/Content/pages_email_custom_controller.htm

Thanks,

Urvik
Sonam_SFDCSonam_SFDC
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:

http://stackoverflow.com/questions/13701379/apex-code-to-send-email-alert
http://www.sfdc99.com/2014/03/01/sending-emails-using-apex/
http://teachmesalesforce.wordpress.com/2011/06/05/sending-more-than-10-e-mails/

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.
UrvikUrvik
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.