I need to attach an excel file to an email. How can I do it?


Hello, welcome to the forum.

See here how to attach files to mail: https://www.outsystems.com/forums/discussion/29128/send-email-with-attachment/


I used the Upload widget to upload the file and I need to fill in the "File Content" field of the Attach File widget within the email preparation. How can I pass the excel file (binary data) for this field?


You must save it to a local variable and pass it as input parameter when calling the Send Mail, or save it to database and pass the Id so you can fetch it from the database, inside the preparation.



I can't set an input parameter in the email with type Binary Data.


The usual would be to save it to database and fetch it from inside the preparation in the eMail page.
You can (but it is not recommended), to use a Session Variable (they can be of type binary), but this will probably have performance impacts in your application... 

Hello Catarina

This is what you should do:

1. Upload the file using the upload widget to a binary var.

2. Then create a text variable. 

3. Convert the binary file variable to the text variable using the BinaryToBase64 logic action from the BinaryData extension - you will have to locate this extension in dependencies and create a reference to the action.

4. Save the converted file into the text variable and send that text variable into your email.

See my screenshots.

Hope it helps.


Nice solution, Vonnelize :)
I never remember to convert binary to base64 :)

Thank you Eduardo and Vonnelize,

In my case, on the homepage I needed to convert a binary variable to text to pass it as an input parameter to the email, and within the email preparation I converted the text variable to binary again to insert it into the AttachFile.

                                                                       Homepage -> Send Action


                                                                        Email1 -> Preparation

Thank you very much for your attention :)