Developer forum

Forum » Templates » Razor EmailMessaging template tags

Razor EmailMessaging template tags

Finn Frost
Reply

When using the new online marketing module, i have a few template tags i can use in my (Email marketing) templates(html), however, i would like to know how to retrieve these values using razor:

 

<!--@EmailMessaging:Recipient.Id-->
<!--@EmailMessaging:Recipient.Email-->
<!--@EmailMessaging:Recipient.Key-->
<!--@EmailMessaging:Recipient.Name-->

 

 


Replies

 
Mikkel Ricky
Reply

In Razor you just write @GetValue("EmailMessaging:Recipient.Id") in stead of
<!--@EmailMessaging:Recipient.Id--> as you would in an html template.

You can use Convert to Razor in the file editor to convert an existing html template to Razor. The Razor template may need some manual tweaking afterwards. 

 

 

 
Finn Frost
Reply

Thanks for your Reply Mikkel.

 

Although, your solution does not work.
In Email Marketing, your point to a page, which is used to send as a newsletter. I have a very simple, MasterPage-, Page- and Paragraph Template for the newsletter(page).

Although, if i change from HTML to Razor, no values are displayed.
Take my page template, in Razor:

 

<!--@MasterPageFile(Nyhedsbrev_Master.cshtml)-->
<!--@Layout.Title(Nyhedsbrev - Standard)-->
<!--@Layout.Description(Template til standard nyhedsbrev)-->


Sidetemplate key: @GetValue("EmailMessaging:Recipient.Key") <br />
Sidetemplate Name: @GetValue("EmailMessaging:Recipient.Name") <br />
Sidetemplate Id: @GetValue("EmailMessaging:Recipient.Id") <br />
Sidetemplate Email: @GetValue("EmailMessaging:Recipient.Email") <br />

Sidetemplate DomainUrl: @GetValue("EmailMessaging:Message.DomainUrl")

<br />
<div class="dwcontent" id="indhold" title="indhold">
  
</div>

And here in Html:

 

<!--@MasterPageFile(Nyhedsbrev_Master.cshtml)-->
<!--@Layout.Title(Nyhedsbrev - Standard)-->
<!--@Layout.Description(Template til standard nyhedsbrev)-->

Recipient id: <!--@EmailMessaging:Recipient.Id--><br/>
Recipient email: <!--@EmailMessaging:Recipient.Email--><br/>
Recipient key: <!--@EmailMessaging:Recipient.Key--><br/>
Recipient name: <!--@EmailMessaging:Recipient.Name--><br/>

Message DomainUrl: <!--@EmailMessaging:Message.DomainUrl--><br />

<div class="dwcontent" id="indhold" title="indhold">
  
</div>

When i use the Html template, then the values of the templatetags are displayed in the email, but when using the razor template, then the values aren't displayed in the email.

 
Mikkel Ricky
Reply
The EmailMessaging tags are not real template tags, but email specific placeholders that uses the same syntax/format as real template tags.
 
These placeholders are not processed by the template engine (html or Razor), but are handled by the email messaging system itself, and therefore you have to use the <!--@…--> format for the email placeholders even in a Razor template.

This is confusing and we're fixing this in 8.4 so you can use double braces for the email placeholders:

Recipient id: {{@EmailMessaging:Recipient.Id}}<br/>
Recipient email: {{@EmailMessaging:Recipient.Email}}<br/>
Recipient key: {{@EmailMessaging:Recipient.Key}}<br/>
Recipient name: {{@EmailMessaging:Recipient.Name}}<br/>

Message DomainUrl: {{@EmailMessaging:Message.DomainUrl}}<br />

I hope this answer makes sense.

  

 

 

You must be logged in to post in the forum