Creating Email Templates

CustomTemplates.xslt extends the Cartella email system by making it possible to create custom emails. EmailContentController, a C# class in Cartella, handles custom emails.

To create a custom email template:
  1. Call the SendMail method on the EmailContentController class, passing in the value of emailContentKey to the SendMail method.
    The SendMail method sends the following information to the CustomTemplates.xslt stylesheet for processing:
        <Content EmailType="emailContentKey">
    • Base URL: This is the URL of the server where your instance of Cartella lives. You need this URL for adding links to, and images from, the Cartella site. For example, you can add an image to your email by using the following code: <img src="{@URL}/Images/MyImage.jpg"/>
    • Type of Email: This is the value of the EmailType attribute in the <Content> element. It will be populated with the value of emailContentKey that is passed to the SendMail method.
    • Content: The inner value of the <Content> node is populated from the variableToValue dictionary that is passed to the SendMail method. Each key in that dictionary becomes an element, with each value populated with the value from the dictionary.
      If you would like to add your own dictionary inside the <Content> tag, make sure to use the XmlSerializableDictionary class. Remember that ToString will be called to get the keys and values. Make sure that the key will become a valid XML element name.
  2. Make the appropriate change to the sample template in the CustomTemplates.xslt stylesheet.
    <!-- Sample Template -->
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl=""
     <xsl:template match="Content[@EmailType='emailContentKey']">
        Here is the value of Key1: <xsl:value-of select="Key1"/><br />
        Here is the value of Key2: <xsl:value-of select="Key2"/><br />
        Here is the value of Key3: <br />
        <xsl:for-each select="Key3/*">
            <xsl:value-of select="name()"/>:<xsl:value-of select="."/>
            <br />
  3. Save CustomTemplates.xslt.