Kentico 13 - How to add BCC to the marketing email?

Dilip Thakuri asked on November 9, 2022 13:41

I want to add BCC to the marketing email. Is there any way to do that?

Image Text

I tried using the below code. It works for email templates, but it does not work for email marketing.

public override void Init()

{

    EmailInfo.TYPEINFO.Events.Insert.Before += Email_Insert_Before;

}


private void Email_Insert_Before(object sender, ObjectEventArgs e)

{

    var email = e.Object as EmailInfo;
    email.EmailBcc = "admin@company.com";
    EmailInfo.Provider.Set(email);
}

Recent Answers


Dmitry Bastron answered on November 15, 2022 10:12

Hi Dilip,

I think you can easily set Bcc in Marketing Automation only for Transactional emails via email template, not for the marketing emails. And the main issue why it's not firing the event you're hooking into is because marketing (also known as "newsletter") emails are sent via slightly different routine without creating EmailInfo object. You can reverse engineer how it works if you look at the CMS.Newsletters.SendNewsletterIssueAction class.

Now, the easiest way to implement what you need would be to hook into actual emal sending part by implementing custom email provider. However there you'd only have email message itself without clear distinction where this email was generated from (could be account emails, ecommerce, newsletters, transactional, etc). Otherwise, you'd probably need to implement your own custom marketing automation action that will suffice your needs.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.