Absolute URI to image

Magnus Rahl
Member since: 2008

A customer uses the ability to have a custom e-mail body for subscription emails, which works nicely (CMS 5 R2 SP1). However, they would like to put images in the email body. The problem encountered then is that because images selected in the editor will be rendered with paths relative to the site root, which will not work in the e-mail body.

Is there a way to insert an image with an absolute URI (like when inserting a link to an external site) without having to edit the HTML? The relative URI of an image selected can be prepended with http://.... to get an absolute URI, but this will cause an error in the image editor (not really a problem, but confusing for editors).

#30243 Jun 09, 2009 7:13
  • Mari Jørgensen
    Member since: 2003

    You can create your own SubscriptionHandler which inherits default behavior from EPiServer.Personalization.SubscriptionMail.

    You should then override the FormatPageForBody method (use .NET Reflector to see how it's implemented by default),
     and then just add the http://siteurl to all image links.

    When you're done, remember to set your handler as the default subscription handler in your EPiServer site.

    #30246 Jun 09, 2009 8:12
  • Magnus Rahl
    Member since: 2008
    Thank you. I had struck me to do this, but I hoped there would be a simpler more genreal way.
    #30247 Jun 09, 2009 9:37
  • Magnus Rahl
    Member since: 2008
    I ended up subclassing SubscriptionMail. But even though I have changed the setting in web.config the custom handler is not called, and I can not select it in the Config-System Settings in admin mode (I don't know if I should be able to, but it states that EPiserver standard is used which makes me suspicious). In the comments to the blog post http://labs.episerver.com/en/Blogs/Mari-Jorgensen/Dates/112298/5/Overriding-subscription-email-formatting/ someone seems to have the same issue.
    #30332 Jun 11, 2009 16:27