0

I have created an email template, added the layout and connected it with the .html file.

The .html file has tag with the srs property set.

In my email when we go to EXM the image is missing since I don' really know how to insert it in the html vie Sitecore. Can someone explain what do I need to do to insert the image in the email or how that img tag should look. I have added the image to my Sitecore Media Library.

2

I have seen two images - 1.Habitat logo (Header section) and 2. Image (Body section) in the "Sample Newsletter template", a built-in EXM message template that comes with EXM installation package.

If you have not seen, please refer this image given as reference

Sample Newsletter body on-edit mode

From ImageSection.cshtml file (C:\inetpub\wwwroot\MySitecoreInstance.local\sitecore modules\Web\EXM\layouts\SampleNewsletter), I infer that there are two possible ways to embed an image in a .cshtml file.

1.<center style="font-size: 0"> @Html.Sitecore().ImageField(Templates.SectionContent.Fields.Image, mw: Model.NewsletterOptions.MaxWidth, item: Model.ContentItem) </center>

2.<center style="font-size: 0"> <img src="@Model.ContentItem.ImageUrl(Templates.SectionContent.Fields.Image, new MediaUrlOptions {MaxWidth = Model.NewsletterOptions.MaxWidth})" alt="" width="100%"> </center>

ImageSection.cshtml The screenshot of Imagesection.cshtml

NOTE: If you are not aware, you can also have a .cshtml file for your layout as "Sample Newsletter message template".

(Sample Newsletter) Layout.cshtml

Do let me know, if you have any problems in my answer, I will try to answer to my best. Thanks!

| improve this answer | |
  • Thank's that is a good idea, I have changed my .html to .cshtml and now everything is breaking because my styles are in the same file..I have to move them I guess but not sure where? – Bojan Tomić Nov 2 '18 at 13:30
  • @BojanTomić - Sorry, I'm not able to understand your comment, maybe if you can share your .html or .cshtml file or some screenshots, definitely some people can really help you out. As far as styling in .cshtml is concerned, the 4 ways to add CSS styling (You may know them) 1)Refer stackoverflow.com/a/13144260/10329199 2)'<center style="font-size:0">' 3)'<style>body {margin:0; }</style>' 4)'<table bgcolor="@Model.SectionOptions.BackgroundColor" style="background-color: @Model.SectionOptions.BackgroundColor">' Refer \sitecore modules\Web\EXM\layouts\SampleNewsletter\Header.cshtml – Paulson Maclean Nov 3 '18 at 6:03
0

I was able to solve this, I have made .cshtml view inside my Visual Studio and connect them with Message Root vie the Layout. Added a new Layout in Sitecore and in the field path added a path to my .cshtml view. Then added in Thamplates/Branches new branch and in it created new Message Root, as explained in documentation EXM Create custom template

Then the Message Root needs to be connected to the layout. You click on Message Root and in Configure tab you go to details, pop up will open and there you can add the layout.

Hope this helps someone it took me a while to get this working.

For start I have just added a static .cshtml page and then I have added the fields and Template.cs

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.