I am trying to bcc a user while sending mass email using MassEmailMessage. Can someone please help. Code snippet :

String[] bccAddress = new String[] {'contact@testcompany.com'};
Messaging.MassEmailMessage CPMail = new Messaging.MassEmailMessage();
CPMail.setSenderDisplayName('Sam Will');

I get this error when I try to save it :

Error: Compile Error: Method does not exist or incorrect signature: [Messaging.MassEmailMessage].setBccAddresses(LIST)


setBccAddresses is a Single Email Message Method. Only Base Email Message Methods and those methods that are specific to the Mass Email Message Class are permitted when sending bulk emails via Apex.

Using a template, you would need to either assign a WhoID to the BCC field of your template or else use the setTargetObjectIds method to assign other values to the template's BCC field when running your Mass Email job.

Note: As I'm certain you seem to be aware, your org would also need to have BCC Compliance Enabled.

 Replace this line with below code
 String[] bccAddress = new String[] {'contact@testcompany.com'};

 List<String> bccAddress = new List<String>();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.