EXM: Custom Email Template
One of the strengths of Sitecore is the customization capabilities. Let's check what is needed to create a custom template.
This blog is based on the official documentation, you will find 3 post for 9, 9.3 and 10.1 versions, pretty much the same steps. Just do not forget the placeholder part.
- Build a custom message template
- Walkthrough: Building a custom message template 10.1
- Walkthrough: Building a custom message template 9.3
- Walkthrough: Building a custom message template 9.0
Also, I got support from the this blogpost Creating a custom email template. This is a great review about EXM
Creating a custom email template has 5 main steps:
- Branch Template
- System Template
- Rendering
- Layout
- Placeholder
Branch Template:
Create a new branch at this path "/sitecore/templates/Branches/System/Email/Messages/<<Custom Newsletter>>". Change the icon to make it easier to identify it and also you can change the thumbnail which will be more representative at the EXM panel when we add it. The item just created comes from a "sitecore/templates/System/Branches/Branch" and contains a item $name which must be AB Testable Message template.
System Template
Create a template at "/sitecore/templates/System/Email/Messages/Inner Content/<<Custom newsletter>>" , add the fields needed and bind it to the $name by clicking the $name item and at the Message section got to the Body field and select the just created message root.
Layout
Create a new layout at "/sitecore/layout/Layouts/System/Email/<<Custom Newsletter>>" and add the html from your solution at the Path field in the Data section. You can find a useful layout html template in the documentation links.
Rendering
Create a rendering view "/sitecore/layout/Renderings/System/Email/<<Custom Newsletter>>" pointing to the corresponding view in the solution.
Last steps
Bind the layout with the message template. Go to "/sitecore/templates/Branches/System/Email/Messages/Custom Newsletter/$name/Message root", go to Presentation>Details>Shared Layout and click [No layout specified], here, add the layout just created at layout section and also at controls section, you must add at least "Set Page Title" and the Rendering created and specify the corresponding placeholder.
About placeholders, you will need to add placeholders settings. Go to "/sitecore/layout/Placeholder Settings/Email/<<placeholderCustomNewsletter>>" and set the key and the allowed control.
By now the custom template is all set but you need to make it available in the EXM panel, so go to "/sitecore/content/email/Message Types/Regular/Default" and click Configure>Assign and add the custom newsletter created at branches to the right column. (This step can be done at the automated messages also). Go to EXM panel and create a Regular Email Campaign, you will see template in the options panel also you can identify it by the thumbnail you changed before.
Now you can continue with the flow and test your email template created. For testing you could use the Quick test, just do no forget to use valid email for "From email" field and to add a "Subject".
There is a plenty of captures in the links above so I did not add them. Also, I did no use folders for a convenience matter but will be a good practice to keep any new item in respective folder in case the customization grows with new renderings and data templates.
If you have any question feel free to leave me a comment.