Email Templates

Complete

Email Templates and System Email Templates are used to fill the subject and content of emails.

These can be used when:

  • writing emails
  • sending documents such as invoices or referral letters, via email. Here, the email template is linked to the relevant Document Template and it is normal to set these as System Email Templates so that they are not available to users on the email write screen

That is, System Email Templates are provided to differentiate between templates used for emailing standard documents (e.g. invoices), and the templates available in the Write Email Templates window.
Both Email Templates and System Email Templates may be used for the former, but only Email Templates may be used for the latter.

 

Templates can contain:

The following is a simple template for use when emailing a handout pdf that is not held in the OpenVPMS database - ie you use this template and then manually attached the Kidney function pdf to the email.

The following is a cover note used when emailing an invoice: (this template would be set as the 'Email Template' on the Invoice document template)

The following is used to generate a sexy looking footer block on emails:

See here for an explanation of the fields.

Documents

When the Content Type is Document the following document types are supported:

  • JasperReport (.jrxml), OpenOffice (.odt), Microsoft Word (.doc)
    • The object returned by the Content Source expression will be supplied to the document to support merging.
    • When selected by the email Template option, any parameters will be prompted for.

If the Content Source expression doesn't return a valid object, the document will be converted to HTML without merging.

  • Rich Text Format (.rtf)
    No merging is supported.
  • HTML (.html)
    No merging is supported.

Images

Images are supported, with the following caveats:

  • Images must be URLs, rather than embedded in documents.
    Popular email clients (e.g. GMail and Outlook) don't support embedded images.
  • OpenOffice should be used to merge OpenOffice/Word documents. 
    LibreOffice has a bug where all images are embedded in the HTML, and are therefore not displayable in all email clients.
  • Images may not be displayed automatically by email clients.
    According to this link referring to a study done in 2009, "only 48% of email recipients see images automatically".

See also How To: Email Template Tips - Open Office and How To: Email Template Tips - Jaspersoft Studio

Examples

The following shows the email generated by the invoice cover note template:

The following shows the footer generated by the third template:

Create/Edit/View

Complete

This is the create/edit/view screen for Email and System Email Templates. These are used to fill the subject and content of emails. Both have the same fields and the only difference between the two is that System Email Templates are not available as templates on the Email Write screen.  Both are available as email templates on Document Templates. See here for more background.

 

The fields are as follows:

Name The template name
Description The template description
Subject Type

Determines how the Subject is processed. One of:

  • Plain text - the Subject is inserted into the email subject as plain text
  • Macro - the Subject is evaluated as a macro, and the result inserted into the email subject
  • Expression -  the Subject is evaluated as an xpath expression, and the result inserted into the email subject
Subject The subject to evaluate
Subject Source

An optional expression to select the object to evaluate against. This is only applicable when the Subject Type is Macro or Expression.

E.g. a value of:

$customer

would evaluate Subject against the current customer.

Content Type

Determines how the Content is processed. One of:

  • Plain text - the Content is inserted into the email as plain text
  • Macro - the Content is evaluated as a macro, and the result inserted into the email
  • Expression - the Content is evaluated as an xpath expression, and the result inserted into the email
  • Document - the content is a document. See below.
Content The content to evaluate
Content Source

An optional expression to select the object to evaluate the Content against. This is only applicable when the Subject Type is Macro, Expression or Document.

E.g. a value of:

$patient

would evaluate Content against the current patient.

Active determines if the template is active or inactive. If it is inactive it is not available for selection.

Source Expressions

The Source Expressions can be any expression or variable that sets the object to evaluate the content against.  This can be:

  • a macro variable , ie $customer, $patient, etc
  • a period (.) meaning the current document. This is most useful when creating cover-notes for use when emailing documents via the Print|Email operation.
  • left blank. For pre-filled emails, the invoice or document etc will be passed. In this case, it is equivalent to using a period.
  • an xpath expression returning an archetype object e.g. openvpms:get(., 'patient.entity')

Documents

When the Content Type is Document the following document types are supported:

  • JasperReport (.jrxml), OpenOffice (.odt), Microsoft Word (.doc)
    • The object returned by the Content Source expression will be supplied to the document to support merging.
    • When selected by the email Template option, any parameters will be prompted for.

If the Content Source expression doesn't return a valid object, the document will be converted to HTML without merging.

  • Rich Text Format (.rtf)
    No merging is supported.
  • HTML (.html)
    No merging is supported.