Community

HTML support in mail templates

reply from Juvenal Guzman in jBPM - View the full discussion

Hi,

 

Some old thread but just in case someone still using jbpm 3 and needs HTML support...

 

First, need to establish mimeType, but, current Mail class from jBPM don't support this feature, so I create a new class based on Mail jBPM class (see attach file)

 

The magic is here:

 

 public static void send(Properties mailServerProperties, String fromAddress, List recipients, List bccRecipients, String subject, String text, String mimetype) {
                        ...
               if (text != null && mimetype == null) {
                    message.setText(text);
               } else { // Is another mimeType
                    message.setContent(text, mimetype);
               }
                       ...
     }

 

So finally, on your template needs to set mimeType and HTML content (use CDATA for that)

 


  <mail-template name='task-assign'>
    <actors>#{taskInstance.actorId}</actors>
    <subject>Task '#{taskInstance.name}'</subject>
    <mimeType><![CDATA[text/html]]></mimeType>
    <text><![CDATA[
    <html>
    Hi, Task '#{taskInstance.name}' has been assigned to you.
    <br>
    Go for it, press <a href="#{BaseTaskListURL}#{taskInstance.id}">here</a>
    <br>
    Thanks.
    <br>
    <b>---powered by JBoss jBPM---</b>
    </html>]]></text>
  </mail-template>


 

Remember to set this new class on your jBPM configuration

 

 

    <string name='jbpm.mail.class.name'  value='com.gucoba.jbmp.mail.MailAction' />

 

And here comes some nasty, as you know, your current deployed process needs to take this need parameter, so you have two options:

 

1. Redeploy your process

2. Update process variables on database

 

See this url for more information http://www.redhat.com/docs/en-US/JBoss_SOA_Platform/4.3.CP02/html-single/JBPM_Reference_Manual/index.html#customizingmailsupport

 

Enjoy!

Juvs

Reply to this message by going to Community

Start a new discussion in jBPM at Community