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
hy.lim1.3897974166558203E12hy.lim1.3897974166558203E12 

Can Salesforce SingleEmailMessage do not send to CC list?

Hi, I have a custom button which will send a SingleEmailMessage and below is my SingleEmailMessage code

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(new string[] {'userA@support.com'});
mail.setCcAddresses(new string[] {'CC_User@support.com'});
mail.setSubject('Testing Subject');
mail.setPlainTextBody('Testing Body');
mail.setReplyTo('UserB@support.com');
mail.setSenderDisplayName(UserInfo.getUserEmail());
Messaging.SendEmailResult[] res = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

Everything works fine but can I not to send this email to user under CcAddresses?

I wan userA to receive the email but not CC_User, so when userA pick up the email and reply, he will see reply To UserB@support.com and CC to CC_User@support.com

Thanks
ShashForceShashForce
Hi,

setCcAddressessetCcAddresses is optional, you can leave it out. Please see this: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_email_outbound_single.htm

If this answers your question, please mark this as the Best Answer for this post, so that others can benefit from this post.

Thanks,
Shashank
hy.lim1.3897974166558203E12hy.lim1.3897974166558203E12
Hi Shashank, thanks for your reply! 

I have to setCcAddresses because I want userA to have the CC recipient when he pick up the email
ShashForceShashForce
Hi,

We cannot setup the CC address when the user is replying. What we can do is to use apex email services (inbound email handler) to send a copy to the CC user once the user replies.

Please see this on how to handle inbound email: https://developer.salesforce.com/page/Force.com_Email_Services

Thanks,
Shashank