Manage multiple email channels
Having multiple email channels within a single Xperience by Kentico application provides flexibility in how you communicate with your audiences. You can use different sending domains for each channel, which makes it easier to tailor communication to specific regions, brands, or customer segments. Multiple channels also let you distribute different language variants of emails, which a single channel doesn’t support.
This page provides best practices for organizing the code of multiple email channels within one Xperience project.
The required level of code separation depends on the content model each channel uses. In most cases, you’ll want to treat them as independent, with separate content types and Email Builder components for each channel. However, if your email channels share an identical content model, you can often treat them as a single channel and reuse your code without any issues.
To implement multiple email channels:
- Create and configure your email channels in the administration interface.
- Organize the project structure and content types according to the recommendations below.
Content types
Use a unique namespace in the code name of content types related to a specific email channel. This prevents conflicts when implementing various features related to content types.
Generated email model classes
For smaller projects, you may store your generated email model classes directly in the main Xperience project.
For larger solutions, where Email Builder components may be placed in dedicated Razor class libraries (RCLs), the model classes must also be available to those RCLs. In this case, we recommend storing your generated email classes in a dedicated Class library project for all generated model classes and reference it from the main Xperience project as well as from any Email Builder RCLs.
Email Builder
Use Razor class libraries (RCLs) to organize the code of your Email Builder components if you plan to create a large number of Email Builder components. For smaller projects you can store your components directly within the main Xperience project. Your components can be shared depending on your implementation.
We recommend structuring your solution with separate projects for each channel, as well as an optional shared library for components shared across your channels:
- AcmeEmail – RCL for the Acme email channel
- DancingGoatEmail – RCL for the Dancing Goat email channel
- Shared – optional RCL for Email Builder components common to multiple channels
- Xperience – the main web application project containing startup code, system data, and configuration. For example:
- Startup and general system configuration (could be based on the Xperience Boilerplate project template)
- Binary data of content item assets
Widgets and sections
- Store the code of general components in a shared location. Components specific to an email channel can be stored in a corresponding RCL.
- Restrict widgets and sections using the
AllowedWidgets
andAllowedSections
properties of theEditableArea
razor component used to define editable areas in email templates.
Email templates
- Store email templates for each email channel in their corresponding RCL, e.g., <AcmeEmail project>/EmailTemplates.
- Scope email templates to certain content types using the
ContentTypeNames
parameter of the registration attribute.