Alternate templates with Mail engine

I recently downloaded the excellent package Mail Engine from Tim’s blog.  This package rocks.  One issue I had was being able to have an alternate template for the newsletter im sending out. A newsletter template with minimal furniture would be ideal. However the current version of mail engine does not support alternate templates.  So I did the following:

  1. Created newsletters doctype with one property umbracoNaviHide (true/false)
  2. Created newsletter doc type with one property with alias sourceNode and type content picker.
  3. Created a node of type newsletters in the root of the site
  4. Created a node of type newsletter in newsletters (step 3) and picked the document I wanted to email using the content picker
  5. Added XSLT macro called GetContentForEmail that i created which has the following code
    <xsl:if test="$currentPage/data&#91;@alias='sourceNode'&#93;!='' and umbraco.library:QueryForNode($currentPage/data&#91;@alias='sourceNode'&#93;)">
    <xsl:value-of select="umbraco.library:GetItem($currentPage/data&#91;@alias='sourceNode'&#93;, 'bodyText')" disable-output-escaping="yes"/>
  6. Created template for newsletter that uses macro from step 5 and in head tag added style tag with styles for formatting the page

I then sent this page as an email.  Bascially now works like ultrasimple mailer used to.


4 thoughts on “Alternate templates with Mail engine

  1. I needed to make some customisations to the way MailEngine works for a project I was working on. Tim was kind enough to share the source and I made an amendment to allow end-users to select from the allowed templates supported by the node to be emailed this allowed a specific email template to be used when mailing out a node. A different approach with the same goal.

    Good idea about the Google Tracking links!

  2. russel roberts says:

    Nice, I think the MailEngine was great. For a project I was working on, I needed to have a specific email sent out when the client created a type of page. Umbraco and the MailEngine were perfect for this. It allowed me to basically create a node with pre-styled documents as emails which would then be sent out based on a specific action. Much like how triggers work in SQL. Will post a package or the code and a demonstration sometime in the future.

    Great work guys, viva l’umbraco!!!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s