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

Set record owner in from address in email sending from apex class


I have a requirement that email sent from apex class is need to set from addresss as Lead owner. In my org there are number of users, so, we can't add all those users in Organization-wide-address. So how can I set the from address(Name and email) ?
NagaNaga (Salesforce Developers) 
Hi Chiruganta,

Please see a sample code and a link below which gives the complete information on this 

User-added image

Best Regards
Naga Kiran
Prosenjit Sarkar 7Prosenjit Sarkar 7
Hi Chiruganta,

Do you have the Lead information in your apex class ? 
Hi Prosenjit Sarkar,

Yes, I have lead information in my class. I need to send an email to that lead from lead owner. I know we need to add email in Organization-wide-email addresses but there are so many users in my system. It is difficult add all of them in Org-wide-address.