Send Email with a File/Attachment

Hi guys, so I have a process where I would like to send an email with a file.
So far the email part is working as it should, but I’m having some difficulties regarding the file sending part.


This is my process, is very simple just so that I could learn how to get this to work.
In the first task the user uploads his file (this part is working fine) and I thought that merely referencing it in the connect input of the email task was enough but it isnt, this is what appears.

Please whoever knows how to solve this or how to do it correctly reply!!
Thank you in advance!!

Hello @paulo.ferreira ,

what does the implementation of your send mail task look like? I would like to see the implementation.

Jonathan

Hello @jonathan.lukas , basically what I did was use a send mail connector for the implementation, like in this git: GitHub - camunda-community-hub/camunda-platform-7-mail: Mail connectors for Camunda Platform 7.

Paulo Ferreira

Hello @paulo.ferreira ,

I see. To send attachments, they need to be present as file. The path to the file has to be attached as string.
Please find an example here:

I hope this helps

Jonathan

Thank you very much. I will look into it!

1 Like

Hi @jonathan.lukas

So… after seeing that example I understood some parts of it, like the file being present in the process (which I already did in mine), but now since that example works in a specific manner I can´t seem to understand how to migrate that to a simpler process.

I already have the file in my process, but now how do I define the input connector of the send email service task in order for it to be sent?

Best regards,
Paulo Ferreira

Hello @paulo.ferreira ,

in fact, the file itself (meaning the blob) does not need to be present in the process rather than in the file system. The process instance should only hold the information about where the file is.

This information (as string) can then be used to fill the input parameter fileNames. This is exactly what the example shows.

If the file is present in the process (the BLOB), right now you would need to save it to your file system first and read it from there. I don’t like this solution and would rather go for creating a feature in the mail connector that lets you send files that are present as process variables directly:

  • creating an issue if not yet present in the mail connector
  • providing a PR that adds the new feature

If assistance is needed, please tag me on the github issue and I will be happy to help you.

Jonathan

So basically what I wanted is more simple than I thought I just need to add the inputConnector as “fileNames” and input the path of the file itself. For anyone trying to do what I did here’s a screenshot of the inputConnector and how I set it up.

This example only works if u want to send an existing file in your system, if you want to upload a file and then send that same file it doesn’t work like this (It’s more complex) !!

attachment

1 Like

Hello @paulo.ferreira ,

I created an issue as I can see that this behaviour is slightly frustrating when using process variables only.

Jonathan

1 Like