Issues Attaching Make-Created CSV File To M365 Send Email

:bullseye: What is your goal?

Create a CSV from a Data store, then attach that CSV to an M365 Send Email action.

:thinking: What is the problem & what have you tried?

The Data attribute for attachments requires the data to be in the buffer format, so if I include the previous step’s output as-is it throws an error. Wrapping it inside toBuffer() does allow the email to send, but the file isn’t correct.

I include the output bundle for the CSV creation step, with the necessary data redacted.

:clipboard: Error messages or input/output bundles

Value can’t be casted as buffer for parameter ‘data’.

[
    {
        "text": "\"Customer\",\"ID\",\"Industry\",\"Industry (Other)\",\"Location\",\"Sales Representative\",\"Title\"\n\"Company Name\",\"13599\",\"Land Clearing\",\"\",\"Boca Raton, FL, USA\",\"Sales Rep Name\",\"Automation Test\"\n\"Company Name\",\"13599\",\"Land Clearing\",\"\",\"Boca Raton, FL, USA\",\"Sales Rep Name\",\"Automation Test\""
    }
]

:camera_with_flash: Screenshots (scenario flow, module settings, errors)

1 Like

Hi @AirBurners

Have you tried the toBinary() function?

This works for me:

@damato

I tried that, but all it does is create a CSV with the first cell having the text {object}.

I get it.

The problem is that you are mapping the full result of the Search Data Store to the Create CSV module. The Record from the Data Store is read by the CSV module as an [object Object].

Parse the Data Records first as a JSON Object and map all the resulting fields of the JSON object in the Create CSV module.

Something like this:

Then apply toBynary() as shown before.

@damato