A common request is to automatically CC a user on every outbound email that Business Central sends via SMTP — useful for sales teams who want a copy of every invoice or order confirmation dispatched under their user account. The cleanest way to implement this without modifying base objects is to subscribe to the OnBeforeSentViaSMTP event on the Mail Management codeunit. The subscriber reads the CC email address from the sending user's User Setup record and appends it to the CC list before the message is handed off to the SMTP connector. The same event exposes the To address, Bcc list, subject, and body, so you can extend this pattern to modify any of those fields as well.
codeunit 50100 "Email CC Subscriber"
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Mail Management", 'OnBeforeSentViaSMTP', '', false, false)]
local procedure OnBeforeSentViaSMTP(var SMTPMessage: Codeunit "SMTP Message")
var
UserSetup: Record "User Setup";
CCEmail: Text;
begin
if not UserSetup.Get(UserId()) then
exit;
CCEmail := UserSetup."E-Mail";
if CCEmail = '' then
exit;
SMTPMessage.AddCC(CCEmail);
end;
}
The subscriber is intentionally minimal. If User Setup has no record for the current user, or if the email field is blank, the procedure exits without making any changes. This makes the feature entirely opt-in: only users who have an email address configured in their User Setup record will have automatic CC applied to their outbound messages.