Attach PDF file to Sendgrid Mail

Hi all,

I'm struggling to send an email via Sendgrid with an PDF attached.

I get the PDF from an external API, create a file resource and store it in the database.

To send the PDF base64 encoded to Sendgrid, I use the "GET FILE RESOURCE DATA" function to get the raw data and base64 encode it. If I take the generated string, I can decode it back to the PDF using a Converter-Tool. It shows me the the encoded file is indeed the representation of the PDF.

If I send this string to sendgrid, I get the error:

code: ERROR_CODE_INPUT_ERROR,
message: Value is not properly formed.,
param: attachments.0.content

Here is the function stack

Any idea what I'm doing wrong? Your help is very appreciated.

2 replies