Print this page

Override from address using SingleEmailMessage

Knowledge Article Number 000193208
Description How to setup/override in salesforce From address using SingleEmailMessage? 

You can use the setOrgWideEmailAddressId(ID) instance method of SingleEmailMessage. To do this, first you have to setup your org wide default email address by going to Setup -> Administration Setup -> Email Administration -> Organization-Wide Addresses menu.. You can then get the ID of that email from the URL and use that in the instance method. 

OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address = ''];
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
if ( owea.size() > 0 ) {

promote demote