Wednesday, March 12, 2025

D365 F&O Email distributor batch add CC

 Well, it has been a while since my last post... So here go...

I recently had the requirement to have CC ability with our emails that I am created via code. We, however, use the SysOutgoingEmailTable and Email templates to send our emails.  The SysOutgoingEmail has no CC field.

Here is my solution.

Create a new extension and add a new field (I created an EDT that extends SysEmailRecipients) to the SysOutgoingEmailTable.

Create extension of SysEmailDistributor class and create chain of command call on initializeMessageBuilder method.


In this chain of command, use the messageBuilder object to 'addCc'.  I also break my field up by ';' because I will have, potentially, multiple email addresses.

Lastly, you need to create your own class and batch job to run for this:


I'm not sure why, but the chain of command isn't enough as the standard SysEmailDistributor won't pick it up. Once you create your own class and a batch jobs, you are all set.
You then simply need to populate your custom field with the CC addresses when creating your email in your code.

That's it!