1

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.

1
  • Could you share the VF code for the template? Commented May 21, 2015 at 15:50

1 Answer 1

0

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 = '[email protected]'];
    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    if ( owea.size() > 0 ) {
        mail.setOrgWideEmailAddressId(owea.get(0).Id);
    }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .