1 2 Previous Next 22 Replies Latest reply on Mar 23, 2010 2:38 PM by juvs Go to original post
      • 15. Re: HTML support in mail templates
        shantanu.u

        The doc says something to this effect - if you define a template, it overwrites values from tags defined in the processdefinition. The process definition allows me to have mail, subject, to, text, etc. I've been asking you this all along - what links the notify and reminder to the mail in the first place? Anyway, I have my answer now. My reminder is still not working but I'll get there soon.

        My template has BaseTaskListURL variable. That's not getting displayed in the email but the task Id is. I've copied it exactly like the doc.

        • 16. Re: HTML support in mail templates
          kukeltje

          You've not been asking *me* that all along, you asked the forum. So many things are asked in one way or another that often things get lost. E.g. look at the subject of this topic and your last question... totally not related.... So I'm sorry you've been asking this all along.... funny thing is that I'm still not sure what 'this' is and have no intend to re-read the whole topic....

          Better luck next time

          • 17. Re: HTML support in mail templates

            I'm using version 3.2.5 and this is the configuration that I'm using...

            <mail-template name="task-creation">
             <subject>New Task Created of process: #{processDefinition.name</subject>
             <text>
             [html]
             [head]
             [title]JBPM Notification[/title]
             [/head]
             [body]
             html text here
             [/body]
             [/html]
             </text>
            </mail-template>
            

            once you have this config file (called jbpm.mail.templates.xml) you must create a MailHandler class where you have to do the overwriting of the '[]' for '<>'.

            Here http://blogs.dfwikilabs.org/pigui/files/2008/02/mailjava.txt you have an example. Then, in the getText() method is where you will have to do the replacement.

            Don't forget to set the content-type to 'text/html'

            I hope this helps...

            • 18. Re: HTML support in mail templates
              kukeltje

              uhmmm.... why not use a cdata section?

              • 19. Re: HTML support in mail templates

                I'm not saying not to use it, I'm just sharing my experience in this matter.

                With your approach, using CDATA sections, did you find any problems with the encoding? because I did !!! I mean, were you able to use symbols (like start and end tag), because I'm facing that problem with a JAXB marshaller.

                Using CDATA and setting content-type to 'text/html' were enough to have an HTML mail working ?

                Thanks,

                • 20. Re: HTML support in mail templates
                  kukeltje

                   

                  "ggamietea" wrote:
                  I mean, were you able to use symbols (like start and end tag),

                  Yes

                  "ggamietea" wrote:

                  because I'm facing that problem with a JAXB marshaller.

                  I'm not using a JAXB marshaller

                  "ggamietea" wrote:

                  Using CDATA and setting content-type to 'text/html' were enough to have an HTML mail working ?

                  Yes

                  • 21. Re: HTML support in mail templates
                    kukeltje

                    I'm surprised noone has ever taken the opportunity to make a contribution for this. As mentioned before, lots of people solved it themselves... The only thing we ask is to make it configurable from jbpm.cfg.xml and have make the default non-html, so the behaviour is as it was.... and to provide a simple testcase.... anyone?

                    • 22. Re: HTML support in mail templates
                      juvs

                      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 new 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

                      1 2 Previous Next