Send CSV via email with Workflows

Hi everyone,

I'm trying to build a Workflow that retrieves some data from the database and sends it as a CSV via email. My workflow has 3 blocks:

  1. A PostgreSQL query retrieving the data
  2. A JS block running "Papa.unparse" over the retrieved data to transform it to the CSV format
  3. A SMTP block to send the data via email

Everything is working fine up until the unparse, but I'm not sure how I can make use of the data returned by the JS and plug it into the SMTP query so it's sent as a CSV file via email.

Here's an image of where I'm stuck at. In the SMTP query, I clicked "fx" to set the value dynamically. I then tried using both "{{code}}" and {{}}" as a value, but I then get the error below when I try to run the SMTP block:

Hey @grefosco!

Does it work if you use [{data: {{btoa(}}, name: "attachment.csv", fileType: "csv" }]?

Exact same issue attempting the same thing
three blocks
data query
smtp block = [{data: {{btoa(}}, name: "attachment.csv", fileType: "csv" }]

Tried the suggestion, still the same error "Use File Input component to upload a file and ensure file is uploaded before query is fired."

I found the issue,
Attachments doesn't accept fileType:
it needs contentType: 'csv'

this will work

  data: '{{btoa(}}',
  name: 'fileName.csv',
  contentType: 'csv'
1 Like