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
Rocio VivancoRocio Vivanco 

Batch job sends email with the sender email address of user who started the job and not the desired one

Hi all,

I see that even if you set who is the Sender in your email using an email batch job, you will get an email with the sender format:

<> on behalf of <email address of user who started the job>

I don't wish this to appear, even if I uncheck the Email Compliance ID checkbox via Email Administration --> Deliverability I get the wrong sender, that means, the email address of the user who started the batch job.

Now I was trying to use a similiar part of code like this:
// Use Organization Wide Address  
for(OrgWideEmailAddress owa : [select id, Address, DisplayName from OrgWideEmailAddress]) {
if(owa.Address.contains('CSR')) email.setOrgWideEmailAddressId(; }

after adding an organization wide address and using the sender email address for this. But after starting the batch job, this is still sending me an email where the sender email address is the one of the user who started the job and not the given to the owa Variable in the code.

Is there a way or trick to handle this?

Raj VakatiRaj Vakati
Can you try to set setReplyTo and setSenderDisplayName? Can you share code to see the issue 
 // Specify the name used as the display name.
mail.setSenderDisplayName('Salesforce Support');

Rocio VivancoRocio Vivanco
Thanks Raj, but I have already tried and I am still receiving an email with the email address of the user who started the job as sender.