Changes between Initial Version and Version 1 of ClientsPlugin/Actions/SendEmail


Ignore:
Timestamp:
Oct 14, 2008, 9:58:19 PM (15 years ago)
Author:
Colin Guthrie
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ClientsPlugin/Actions/SendEmail

    v1 v1  
     1== Send Email: ClientsPlugin Event Action ==
     2
     3=== Description ===
     4
     5The Send Email action will, unsurprisingly, send an email to a client when the event is triggered. In order to format the XML Summary into an email it uses XSLT to transform it accordingly.
     6
     7The transform will actually be called several times, with different arguments to allow a MIME email encapsulating HTML, text and images to be created.
     8
     9
     10=== Example XSLT ===
     11
     12{{{
     13#!xml
     14<?xml version="1.0" encoding="utf-8"?>
     15<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#160;"> ]>
     16<xsl:stylesheet
     17  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     18  version="1.0">
     19 
     20  <xsl:output method="html" indent="yes" encoding="UTF-8" omit-xml-declaration="yes"/>
     21  <xsl:decimal-format name="GBP" decimal-separator="." grouping-separator=","/>
     22 
     23  <!-- Match the root of the XML render the three views -->
     24  <xsl:template match="/">
     25    <xsl:choose>
     26      <xsl:when test="$view='html'">
     27        <!-- Should return HTML as you see fit -->
     28        <xsl:call-template name="html"/>
     29      </xsl:when>
     30      <xsl:when test="$view='images'">
     31        <!--
     32        Should return a list of images to embed in the following format:
     33       
     34        <images>
     35          <img id="myimage" src="/local/path/to/image"/>
     36        </images>
     37       
     38        Where "myimage" is references in your HTML image as <img src="cid:myimage" />
     39        -->
     40        <xsl:call-template name="images"/>
     41      </xsl:when>
     42      <xsl:otherwise>
     43        <!-- The plain text portion of the email -->
     44        <xsl:call-template name="plain"/>
     45      </xsl:otherwise>
     46    </xsl:choose>
     47  </xsl:template>
     48 
     49  <!-- Simple (cop-out) implementation of a plain text message -->
     50  <xsl:template name="plain">
     51    <xsl:text>
     52This message contains HTML content for a rich display.
     53
     54Please enable the HTML view or use an HTML compatible email client.
     55    </xsl:text>
     56  </xsl:template>
     57 
     58  <!-- This HTML version does not contain any images -->
     59  <xsl:template name="images"/>
     60 
     61  <xsl:template name="html">
     62    <!-- The root element needs to be created with xsl:element to prevent namespaces sneaking in. -->
     63    <xsl:element name="html">
     64      <head>
     65        <title>Ticket Summary for <xsl:value-of select="/clientsplugin/client/name"/></title>
     66     </head>
     67      <body>
     68        <h1>Ticket Summary for <xsl:value-of select="/clientsplugin/client/name"/></h1>
     69        <!-- actually do something clever with the input XML.... -->
     70      </body>
     71    </xsl:element>
     72  </xsl:template>
     73
     74</xsl:stylesheet>
     75
     76}}}