Hello Marketing enthusiasts!

In this blog post I will explain how to use Dynamics content/Custom Code in a Dynamics Marketing Email.

In this example, the goal is to send an email to attendees with their registered sessions. In the schematic overview below the contacts have registered for 1 or 2 sessions.

To send an email with dynamic content based on the session registration of contacts it is necessary via the custom code, it cannot be achieved via the ‘assisted edit’ because it cannot retrieve multiple records. The custom code uses JavaScript that use for each loop, on Microsoft docs there is an explanatory article about how to use custom code works and the ‘assisted edit’, it can be found here.

To start using the custom code we need to navigate to Marketing Emails. Open Marketing Emails and go to the Toolbox tab, then drag and drop the ‘custom code’ tile in the Marketing email.

 

After the custom code tile is placed in the body of the Marketing email click on the blue custom code line that represents (place holder) the custom code. On the Properties tab on the right side of the designer the custom code block will be available.

 The custom code contains the following code:

 

To explain the code used, the relationship name is used in the first part of the #each. In this example a contact with session registrations.

In the second part ‘this.’ the ‘sessionname’ that will be shown in the email.

 You can copy the code below:
{{#each contact.msevtmgt_sessionregistration_contact_msevtmgt_contactid}}
{{this.bbhhs_sessionname}}
{{/each}}

Underneath the explanation that can be found on Microsoft docs.

 

After adding the custom code, open the html to adjust it with the “<ul> </ul> and <li> </li>” tags to sum up the sessions. Make sure to put it in between the <div> tags.

After saving the email and going live the designer will show the custom code which is entered in the email.

 

To test and show the session registrations in the Marketing Email register a test contact person on an Event. Go to the Event and then go to the tab Registration and attendance, after this scroll down to the 3rd subgrid and click on new Event Registration.

 

When the Event Registration tab opens connect the test contact and go to the session registrations tab and Register a new session registration.

To test the custom code it is required to send it via a customer journey to your test segment.

In this last screenshot the inbox preview is shown, in this example the 2 registered sessions are shown; 'Accountancy' and 'Bedrijfskunde'