I have a requirement where the ‘from address’ need to be changed . According to business logic cannot use “Organization wide email address”

When ever the record is updated , From address should display Record Owner Name not the one who updated the record .

Code :

     mail.setReplyTo(record owner email);
     mail.setSenderDisplayName('record owner name');

Error : In ‘From Address’ It should display only the record owner name not the one who updated the record**([mailto :[email protected]])**

From: record owner name [mailto :[email protected]] Sent: Friday, February 19, 2016 11:27 AM

  • so what is the real issue here? -- you can fetch the record owner name and email via owner.name and owner.email relationships using SOQL
    – cropredy
    Commented May 19, 2016 at 4:54

1 Answer 1


Here is a Salesforce article on "Setting a 'from' address in SingleEmailMessage".

To do this you must first set up a dedicated email address by navigating to Setup -> Administration Setup -> Email Administration -> Organization-Wide Addresses menu.

Once you have created an org-wide address (note that Salesforce will require you to confirm the address prior to using it, so if you're going to be sending things from a junk address it would be wise to set up a catch-all mailbox so you receive the confirmation email), grab the Id from the URL and use the setOrgWideEmailAddressId(Id)method on your instance of Messaging.SingleEmailMessage. If you want to avoid hard-coding an Id, after creating your Org-Wide Address you can query them:

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

Source - https://help.salesforce.com/apex/HTViewSolution?id=000232863&language=en_US

  • I thought he said he couldn't use org wide default email?
    – Francis
    Commented May 18, 2016 at 7:41
  • Yes without using org wide default email. .. Is there any way ?
    – nam
    Commented May 18, 2016 at 8:20
  • Why there is a negative vote? I know in the question it was mentioned. But my intention is to show how you can create multiple 'Organization wide email address' and use them as per your need.
    – Saroj Bera
    Commented May 18, 2016 at 8:36

You must log in to answer this question.

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