4 Replies Latest reply on Aug 6, 2010 4:19 AM by krixerx

    E-mail attachments

    krixerx

      How to add e-mail attachment dynamically in jPDL?

        • 1. Re: E-mail attachments
          rebody

          Hi Erki,

           

          You could get attachment data from process variable. Like this:

           

          <attachment name='strip.gif' expression='${strip}' mime-type='image/gif'/>

           

           

          Please refer the testcase in svn.

           

          http://anonsvn.jboss.org/repos/jbpm/jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/mail/AttachmentTest.java

          • 2. Re: E-mail attachments
            krixerx

            Hi!

             

            Sometimes i need to add one attachment, sometimes 5 attachments. Is it possible to add attachments dynamically in jPDL (to use "decision" or "foreach" operation under "attachments" element)?

            • 3. Re: E-mail attachments
              rebody

              Hi Erki,

               

              If you want to achieve dynamic attachments when sending mails.  I sugguest you create a custom mailProducer,  Please refer here:

              http://docs.jboss.com/jbpm/v4/devguide/html_single/#custommailproducers

              • 4. Re: E-mail attachments
                krixerx

                I found easy solution. It's not nice but it works.

                 

                i - number of attachments.

                 

                <decision name="sendEmailDecision">
                     <transition to="sendEmailWith1Attachment">
                          <condition expr="#{i == 1}"/>
                     </transition>
                     <transition to="sendEmailWith2Attachments">
                          <condition expr="#{i == 2}"/>
                     </transition>
                     <transition to="sendEmailWith3Attachments">
                          <condition expr="#{i == 3}"/>
                     </transition>
                     <transition to="end"/>
                </decision>
                <mail name="sendEmailWith1Attachment">
                ...
                     <attachments>
                          <attachment file="#{attachmentAddresses.get(0)}" mime-type="txt/xml" name="#{attachmentNames.get(0)}"/>
                     </attachments>
                     <transition to="end"/>
                </mail>
                <mail name="sendEmailWith2Attachments">
                ...
                     <attachments>
                          <attachment file="#{attachmentAddresses.get(0)}" mime-type="txt/xml" name="#{attachmentNames.get(0)}"/>
                          <attachment file="#{attachmentAddresses.get(1)}" mime-type="txt/xml" name="#{attachmentNames.get(1)}"/>
                     </attachments>
                     <transition to="end"/>
                </mail>
                <mail name="sendEmailWith3Attachments">
                ...
                     <attachments>
                          <attachment file="#{attachmentAddresses.get(0)}" mime-type="txt/xml" name="#{attachmentNames.get(0)}"/>
                          <attachment file="#{attachmentAddresses.get(1)}" mime-type="txt/xml" name="#{attachmentNames.get(1)}"/>
                          <attachment file="#{attachmentAddresses.get(2)}" mime-type="txt/xml" name="#{attachmentNames.get(2)}"/>
                     </attachments>
                     <transition to="end"/>
                </mail>