We use multi-page email with a standard email module. The following code snippet is in the service class, so we use the standard groovy templating instead of the gsp engine:
Template template = groovyPagesTemplateEngine.createTemplate(<templatename>)
Writable emailBody = template.make(<data model as map>)
StringWriter bodyWriter = new StringWriter()
emailBody.writeTo(bodyWriter)
String xml = <some xml>
mailService.sendMail {
multipart true
to <recipient>
subject <subject string>
body bodyWriter
attachBytes "filename.xml", "text/xml", xml.getBytes('UTF-8')
}
Most importantly, "multipart true" appears at the beginning of the close. If you add
html '<b>Hello</b> World'
to closing above, I assume that you will receive the text and html email address with the attachment.
source
share