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
Anil DuttAnil Dutt 

Email not go to BCC address

Hi,

i have set a BCC address like this but it does not go out

     Contact con1 =  new Contact();
     con1.FirstName = 'Anil';
     con1.LastName = 'Dutt';
     con1.Email = 'anil@swiftsetup.com';
     insert con1;
                      
     Messaging.SingleEmailMessage mail1 = new Messaging.SingleEmailMessage();
     mail1.setTargetObjectId(con1.Id);
     mail1.setWhatId(opp.Id);
     mail1.setTemplateId('00Xd0000000PJGH');
     String[] bccEmail = new String[]{'anildbest83@gmail.com'};
     mail1.setBccAddresses(bccEmail);
     mail1.setOrgWideEmailAddressId('0D2d00000004D3Z');
     Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail1 });
     delete con1;

Mail goes to anil@swiftsetup.com but not to anildbest83@gmail.com

Any idea?

Best Answer chosen by Admin (Salesforce Developers) 
kiranmutturukiranmutturu

try to use this and check 
mail1.setBccSender(true);

All Answers

kiranmutturukiranmutturu

r u getting any error while doing this? and check If the BCC compliance option is set at the organization level, the user cannot add BCC addresses on standard messages

Anil DuttAnil Dutt

No error and BCC compliance is also not enabled

kiranmutturukiranmutturu

try to use this and check 
mail1.setBccSender(true);

This was selected as the best answer