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
SANDEEP DESHPANDE 18SANDEEP DESHPANDE 18 

Sending email using BCC in Apex code when Compliance BCC Email flag in ON in org.

Hi All 

Need help in using send email in apex using BCC. Our client has enabled "Compliance BCC Email" feature in there box. So what we have understood that we can't use now BCC in Apex code. 

We are trying out of for an option. 

Our requirement is that. 
If there are more than one recipient of the mail, they should not get information that to all whom the email is been sent. So we thought we will use BCC feature of send email in apex.But what we have experinced is apex code throws error stating "when we use Compliance BCC Email we cannot use BCC in apex."


Thanks
​Sandeep
Best Answer chosen by SANDEEP DESHPANDE 18
Rajiv Penagonda 12Rajiv Penagonda 12
You will have to take the route of duplicating the email.

Instead of adding all users to "To" field, create one email each for the users. If you are sending to external email ID's, this approach will actually count against your email limits. However, if you are sending this email to internal users (including portal/community users), use the setter method "setTargetObjectId(targetObjectId)" on the SingleEmailMessage with the corresponding user ID. This will help you work around the limits.

All Answers

Rajiv Penagonda 12Rajiv Penagonda 12
You will have to take the route of duplicating the email.

Instead of adding all users to "To" field, create one email each for the users. If you are sending to external email ID's, this approach will actually count against your email limits. However, if you are sending this email to internal users (including portal/community users), use the setter method "setTargetObjectId(targetObjectId)" on the SingleEmailMessage with the corresponding user ID. This will help you work around the limits.
This was selected as the best answer
SANDEEP DESHPANDE 18SANDEEP DESHPANDE 18
Thank you !! it Worked. 
We were using Portal so we opted the 2nd option what you have given . 

Thanks again !

Cheers
Sandeep