cancel
Showing results for 
Search instead for 
Did you mean: 

How do we use the new MailActivityBehavior with attachments?

ms1
Champ in-the-making
Champ in-the-making
Hello All,

I looked at the source code on github for MailActivityBehavior and see that attachments are now implemented.
https://github.com/Activiti/Activiti/blob/master/modules/activiti-engine/src/main/java/org/activiti/...

How can I incorporate this into the 5.17 build I am using and how do the attachments get specified?

TIA
2 REPLIES 2

vasile_dirla
Star Contributor
Star Contributor
Hello,

this is how you could use attachments:
<code>
<sendTask id="sendMail" activiti:type="mail">
      <extensionElements>
        <activiti:field name="to">
          <activiti:string>kermit@activiti.org</activiti:string>
        </activiti:field>
        <activiti:field name="subject">
          <activiti:string>Hello Kermit!</activiti:string>
        </activiti:field>
        <activiti:field name="text">
          <activiti:string>This a text only e-mail.</activiti:string>
        </activiti:field>
        <activiti:field name="html">
          <activiti:expression>
            <![CDATA[
              <html>
                <body>
                  Hello ${(gender.equals('male')) ? 'Mr.' : 'Mrs.'} <b>Kermit</b>
                </body>
              </html>
            ]]>
          </activiti:expression>
        </activiti:field>
        <activiti:field name="attachments">
          <activiti:expression>#{attachmentsBean.getFile()}</activiti:expression>
        </activiti:field>
      </extensionElements>
    </sendTask>

<code>

ms1
Champ in-the-making
Champ in-the-making
Thanks. This is a pretty straightforward way to do it and it works! I like that the email is still defined in the process diagram … even though this part gets added by hand for now. The only caveat is that expression should use $ instead of #.

I even made a change to my email task in the Eclipse diagram editor and it kept the attachment piece on save. So, this looks pretty solid.

Thanks again for this. It was a big help.