Here’s a small snippet on how add automatic CC for all outgoing emails from Business Central via SMTP.
This methods also works when you want to change To or Bcc or even email subject or body.
This code example below checks if user has email setup and if it has then uses that email to add as CC for all outgoing emails.
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Mail Management", 'OnBeforeSentViaSMTP', '', false, false)]
local procedure AddCCToEmail(var SMTPMail: Codeunit "SMTP Mail")
UserSetup: Record "User Setup";
SendToCcList: List of [Text];
if UserSetup.Get(UserId) then
if UserSetup."E-Mail" <> '' then begin