How to attach a file to email

1
0
-1

Hi,

I can send an email from Bonita ok but haven't managed to figure out how to add an attachment to the email message?

The documentation says "Include email attachments defined as a variables or expressions" but doesn't have any examples. I'm assuming that a Groovy script is needed but can't find anything that I could have applied.

Where could I find an example where the attachment can added to the email, preferable using a variable so that the name doesn't need be hardcoded.

Thanks,
ktp

Bonita 7.2.3 CE

ps. I have the file written to the disk prior sending the email, so the file already exists at the point of creating the email.

1 answer

1
0
-1
This one is the BEST answer!

When it says variable it means document variable as defined in the Pool Documents.

So for example you have a document defined as fred and you want to attach it to an email, in the connector get to that point, add a row and then add the document fred to it.

That's it, no need for groovy script.

regards
Seán

PS: If this reply answers your question, please mark a resolved

Comments

Submitted by kari.paukku on Sun, 05/08/2016 - 21:00

Sean,
thanks - I did find the document section for the lane and created a document called "fred" to which I assigned a file. How could I assign the file name dynamically (the idea is that earlier in the process the file gets created and has a named decided at that point (so every time a unique name). This file should then be assign to document variable ("fred" in this case).

thanks,
ktp

Submitted by kari.paukku on Sun, 05/08/2016 - 21:28

Tested it a little bit more and sending an email with attachment using the document (and selecting the file at the point when creating the document in Bonita, worked fine.

So far no luck trying to have the file name assigned dynamically If I find something I'll update it here.

Submitted by Sean McP on Mon, 05/09/2016 - 05:22

There is no way to interact with the connector dynamically, it is fixed and solid in it's implementation.

I find the inbuilt email connector useful for quick emails only.

To do dynamic work

1) you can assign document variable fred to the email, then you can then assign one of bill.docx, george.xlx, peter.ppt to fred and send that. But you are fixed to only one document...

2) you write your own email connector based on the implemented connector that will accept a list of strings (document variables) which you can then attach to the email.

3) write your own script code similar to these:

http://stackoverflow.com/questions/6806407/add-attachment-as-stream-in-commons-email
https://vangjee.wordpress.com/2010/11/02/how-to-create-an-in-memory-pdf-report-and-send-as-an-email-attachment-using-itext-and-java/

regards
Seán

Submitted by kari.paukku on Tue, 05/10/2016 - 04:45

Sean,

the first ("1) you can assign document variable fred ... assign one of bill.docx, george.xlx, peter.") option would be sufficient for me - will start to have a look how that can be done.
More later as I find out how that's done.

ktp

Notifications