EMail template images

DVS Developers asked on June 29, 2015 12:17

What is the best way to include an image in an email template? My preference would be an embedded attachment using a content ID. How would I do that? What are the alternatives?

Recent Answers


Petr Jiroušek answered on July 21, 2015 08:44

Hi, could you clarify what do you mean by Content ID. There is no such a field with this name in Kentico.

You can either attach files to an email template through the Attachments button (1) or as part of the body (2). 1) Attachment behaves as direct upload only. No reference to content tree. 2) Email template body supports macro syntax. So you can refer any image from the content tree or media library.

Content tree macro example:
{%Documents.Where("NodeID=13")[0].AbsoluteURL%}

Media library image exmpale:
<img src="www.yoursite.com/getmedia/{% AllSites[0].DataContext.SiteObjects.MediaLibraries[0].Files[0].FileGUID %}/{% AllSites[0].DataContext.SiteObjects.MediaLibraries[0].Files[0].FileName %}.aspx" />

You can also create custom reusable macro to simplify your syntax.

Please see also another thread

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.