I wanted a bit more control over the custom email messages that were trigger by my workflow so I used the following mechanism. In the "Condition and Configuration" section I have something like the following:
// Reads a template file from disk and sets ${mailSubject} and ${mailBody}
import groovy.text.GStringTemplateEngine
// insert additional bindings so template can use (for example) ${issue.reporter.displayName}
def binding = [issue: issue]
String TEMPLATE_PREFIX_PATH = "/some/path/to/email/template/foo"
String SUBJECT_TEMPLATE_PATH = TEMPLATE_PREFIX_PATH + "_subject.vm"
String BODY_TEMPLATE_PATH = TEMPLATE_PREFIX_PATH + "_body.vm"
def engine = new GStringTemplateEngine()
def template = engine.createTemplate(new File(SUBJECT_TEMPLATE_PATH)).make(binding)
config.mailSubject = template.toString()
template = engine.createTemplate(new File(BODY_TEMPLATE_PATH)).make(binding)
config.mailBody = template.toString()
// your condition test goes here
return trueThen in the "Email template" section I have ${mailBody} and the "Subject template" has ${mailSubject}.
Hopes this helps others. Any better ways to do it?