Attachment sent from workflow is garbled characters

Hi, I followed the info here and got my workflow to work.

However, the resulting attachment is garbled characters. How do I modify the code to set the content type or encoding correctly?

Screenshot 2024-08-20 at 3.01.10 PM

1 Like

Hi @Carol_Scheible! Thanks for reaching out. :wave:

And great job finding that previous post; it contains a ton of good information. In fact, I'm pretty sure the solution to your problem is one of the things @Kabirdas suggested in that thread - to encode your data string in base64 using the btoa command. Your "Attachment" field should look something like the following.

[ {{ { data: btoa(formatToCSV.data), name: 'attach.csv', contentType: 'csv' } }} ]

I tested it on my end and everything seems to work as expected. Let us know if you run into any additional challenges!

Hi Darren, thanks much for the help. I tried the btoa thing, and it gives an error in the send mail. Unless I put single quotes around it, then I get the same issue with the attachment being garbled characters.


Ah - make sure that btoa is included inside the double curly brackets, as it is JavaScript code and we need it to execute as such. Keep in mind that anything not inside the double curly brackets is being interpreted as a string!

Thanks, that did the trick!
Here is my final code from the Attachment section in case that helps someone in the future.

[{data: '{{btoa(formatToCSV.data)}}',name: "attach.csv",contentType: "application/csv" }]

3 Likes