Pieter Brinkman Blog
Sitecore ECM: How to create an e-mail template from Scratch - Part I

Sitecore ECM: How to create an e-mail template from Scratch - Part I

In this post I will create an e-mail template for ECM from scratch. This article is based on a Webinar (in Dutch) I did about the Email Campaign Manager (ECM) you can see the Webinar on YouTube.       [youtube]hGmzaK79cvI[/youtube] We build a custom template the same way that we build a page. First we will create the templates, than we will create the presentation components and at the end we will bind the presentation components to the template standard values. Let's start building!

Create Basic Newsletter template

1. Open the template manager and create a new template called Basic Newsletter, Select the following base templates /sitecore/templates/Modules/Email Campaign/Messages/Inner Content/Message Root 2. Specify the following fields : a. Title b. Text, set the source property to /sitecore/system/Settings/Html Editor Profiles/ Message Content c. Header Text d. Header Link Text e. Footer Text The Basic Newsletter template in will look like this: Sitecore ECM how to custom template datatemplate 3. Set the following standard values:

FieldStandard value
TitleNewsletter title
TextNewsletter Text
Header TextAre you having trouble viewing the e-mail?
Header LinkText Please click here to see the online version.
Footer TekstFooter HTML: Organization Name, Street, City, Country; "This message was intended for: $email$"; Unsubscribe link

Create Basic Newsletter Branche template

1. Create a branch template 2. Select the /sitecore/templates/Modules/Email Campaign/Messages/Pre-existing page template 3. Rename the create Pre-exiting Page branche template to Basic NewsLetter 4. Underneath the $name item create the Email Message root item based on the Basic newsletter template 5. Underneath the created Email Message root item insert a folder called Message Subjects. This folder will contain all subjects for the e-mail. 6. Remove the folder template to insert options of the Message Subject folder and add the Subject template: /sitecore/templates/Modules/Email Campaign/Messages/Inner Content/Newsletter/Subject. 7. Insert a Subject item in the Message Subject folder with the name Subject 1. The branche template should look like this: > INFO: The $name item will be used for showing an online version of your newsletter and the message preview within ECM. 8. In the content tab of the $name item select in the  Web page  field the Email Message Root item: Sitecore/templates/Branches/Modules/Email Campaign/Messages/Newsletter/Basic Message/$name/Email Message Root

INFO: The $name item will be used for showing an online version of your newsletter and the message preview within ECM.

Create the presentation components

For the basic newsletter we need a few presentation components.

Create the Basic Newsletter Layout

1. Create Basic Newsletter Layout Insert the html-title placeholder in the <title> tag

Add the following table to within the <Form> tag

<table><tbody><tr><td><hr></td></tr><tr><td></td></tr><tr><td><hr></td></tr></tbody></table>

Create the rendering components

1. Create the Basic Newsletter Header rendering. In the Developer Center select Create a New XSLT rendering. Name the rendering Basic Newsletter Header. Copy the following code into the rendering.

[](/?sc_itemid={../@id})
  1. Create the Basic NewsLetter TitleAndText rendering In the Developer Center select Create a New XSLT rendering. Name the rendering Basic NewsLetter TitleAndText. Copy the following code into the rendering.

Set the Parameters Template of the Basic NewsLetter TitleAndText rendering to templates/modules/Email Campaign/ID Source Based Parameters Binding presentation and content

Binding presentation and content

1. In the Basic Newsletter Branche template set the layout details of the Email Message Root item For the default device; - Set the  layout to the Basic Newsletter layout - And add the following controls:

ControlDescriptionPlaceholder
Set page titleRequired for e-mail subject support. Also print the e-mail subject, put this control in the title tag. Preferred use is to dynamic bind this to a placeholder. Set the datasource to: sitecore/templates/Branches/Basic NewsLetter/$name/Email Message Root/Message Subjects/Subject 1Html-title
Basic NewsLetter TitleAndTextShows Title and Text fieldemail-content
Basic Newsletter HeaderPrint the header field, containing a link to the online version.Email-Header

  The dynamic binding of the controls should look like this: Binding presentation and content 2. In the Basic Newsletter Branche template set the layout details of the $name item. This will be the layout settings for the online page. For the default device; - Set the  layout to the Basic Newsletter layout - And add the following controls:

ControlDescriptionPlaceholder
Process Personalization TokensProcesses all tokens like $name$ or $email$ in the e-mail.email-content
Basic NewsLetter TitleAndTextShows Title and Text field Set the datasource to: sitecore/templates/Branches/Basic NewsLetter/$name/Email Message Rootemail-content
Set page titleRequired for e-mail subject support. Also print the e-mail subject, put this control in the title tag. Preferred use is to dynamic bind this to a placeholder. Set the datasource to: sitecore/templates/Branches/Basic NewsLetter/$name/Email Message Root/Message Subjects/Subject 1Html-title

 

Set the insert options

Go to the draft folder /sitecore/templates/Modules/Email Campaign/Target Audience/Drafts  and unprotect  the item. Add the Basic Newsletter Branche template to the insert options.

NOTE: If you already created some target audiences you need to do this for the draft folder of all the target audiences.

Create a Basic Newsletter

Go to ECM select the draft folder and create a Basic Newsletter. The result should look like this: This is the first part of the How To create custom e-mail template for ECM. In part II I will add a listing to the custom… This is a basic Newsletter from which you easily can design different more complex newsletters.

This is the first part of the How To create custom e-mail template for ECM. In part II I will add a listing to the custom e-mail template. Part II will follow in the next week.

Update: Part II can be found here: Sitecore ECM: How to create a Email template from Scratch - Part II