We have a daily scheduled apex job that sends email everyday (we use visuaforce email template). I would like to change "From" email address in one specific visulaforce template. I have already added this email address as Organization Wide address. How can I change "From" email for this template.

  • Could you share the VF code for the template? – Chris Duncombe May 21 '15 at 15:50

Once you have created an org-wide address grab the Id from the URL and use the setOrgWideEmailAddressId(Id) method on your instance of Messaging.SingleEmailMessage.

  OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address = 'doNotReply@blahblah.com'];
    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    if ( owea.size() > 0 ) {
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.