0

Currently I have an Apex trigger on the Account object, such that when the Account name is modified, it sends an email to a specific list of email addresses defined in a custom setting. This is all working fine - however, for some reason, the person who made the update to the Account Name (i.e. the person initiating the trigger code) will always get copied on the email that is sent out to the recipients.

For example, below is a code snippet from my trigger ... even if I just run the code below in the Developer Console, the user running the code will always get copied in the email (in the CC).

List singleEmailList=new List();

// the email addresses will come from custom setting
String[] toAddresses =  new String[] {'test@test.com'}; 

// Email Test 1
Messaging.SingleEmailMessage singleEmail1 = new Messaging.SingleEmailMessage();
singleEmail1.setSenderDisplayName('Salesforce Support');
singleEmail1.setReplyTo('peter@test.com');
singleEmail1.setSubject('Test Email Only');
singleEmail1.setPlainTextBody('Test Email Only ... ');
singleEmail1.setBccSender(false);
singleEmail1.setToAddresses(toAddresses);
singleEmailList.add(singleEmail1);

Messaging.SendEmail(singleEmailList);

Has anyone experienced this? I have looked in various configuration settings but found nothing. The bccSender flag doesn't seem to work either.

Nevertheless, if I run the code in my Developer Edition sandbox, it works fine (running user is not copied)! Not sure if there is some configuration with the Salesforce instance/sandbox at my work somehow?

Any suggestions or workarounds would be appreciated ...

Many thanks! Jeffrey

  • The address is probably in the custom setting record in your work org, if it's working properly in a different org with the same code. Could you provide the record info? – Brian Mansfield Nov 30 '15 at 20:02
  • (1) Your list declaration in the posted code won't compile - probably an oversight copy-pasting; (2) when I posted above in DC, I just get one email - to the toAddress (3) Do you (or the person referenced in the OP) have bcc setup in your Setup | Personal Info | Email Settings ? – cropredy Nov 30 '15 at 22:46
  • I tried the bcc setup (Setup | personal Info | Email Settings) and making sure it is set to "No", but I was still getting copied in the email. :( Our custom setting only have one email right now (for testing purpose), which is for a different person. – Jeffrey Dec 1 '15 at 14:07
0

One more guess:

Check your email settings by navigating to Setup | Email > My Email Settings.
Someone may have added CC/BCC there.

enter image description here

  • Thanks for the responses - I tried the bcc setup (Setup | personal Info | Email Settings) and making sure it is set to "No", but I was still getting copied in the email. :( Anything else that I should look for? – Jeffrey Dec 1 '15 at 14:07

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.