I need to send emails with either 1 or 2 file attachments, depending on a condition. Specifically:
-
File 1 is always attached (from a an HTTP OAuth2.0 Request module)
-
File 2 is only attached if its filename is NOT “No_Intro_Pack.pdf” ( from Google Drive module)
What I’ve tried:
-
Make formulas - Attempted to build an array using
map(),add(), andtoArray(), butmap()doesn’t work for creating key-value structures in Make. -
JavaScript code module - Built the attachments array successfully, but the binary file data gets transformed into a Node.js Buffer format
{"type": "Buffer", "data": [bytes]}which the Email module can’t read. Error: “Value can’t be casted as buffer for parameter ‘data’.” -
Python code module - Same issue as JavaScript - the binary data format gets transformed and breaks.
What I want to avoid:
Using a Router to duplicate my email modules. I currently have 2 email routes and would need to create 4 total if I use Router, which seems excessive for this simple conditional logic.
Question:
Is there a way to conditionally build an attachments array in Make while preserving the binary data format that the Email module expects? Or is Router the only viable solution?
Thanks in advance!