4

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

String[] bccAddress = new String[] {'[email protected]'};
Messaging.MassEmailMessage CPMail = new Messaging.MassEmailMessage();
CPMail.setTargetObjectIds(emailRecipientsList);
CPMail.setBccAddresses(bccAddress);
CPMail.setTemplateId(EmailTemplate.Id);
CPMail.setSenderDisplayName('Sam Will');
//CPMail.setBccSender(true);
CPMail.setUseSignature(false);
CPMail.setSaveAsActivity(true);

I get this error when I try to save it :

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

2 Answers 2

3

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.

-1
 Replace this line with below code
 String[] bccAddress = new String[] {'[email protected]'};

 List<String> bccAddress = new List<String>();
 bccAddress.add('[email protected]');

You must log in to answer this question.

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