Blank Mapped Attachments

I have this scenario where I capture several attachments via HTTP and then I attach them to an email using the HTTP - Get a file mapping.

It happens that in some cases, the attachments do not exist and the lack of that document causes an error in the email module.

I tried to work around it by creating a handler (resume) error in the HTTP module, but this only resolves the error in that module.

The final objective of the scenario is to send the email with any attachments that exist.

The solution I have thought of so far would be to create specific filters for each situation (whether or not each attachment exists), but I would like to know if there is a simpler solution, as my scenario already has several other filters and paths.


image

I tried the alternative of saving each attachment as a variable and saving them all at the end, but the email module is giving an error.



What is the contents of the structure you are finally putting into the email module for attachments? It has to be an array and a valid one at that.

1 Like

Each variable is assembling a part of the Array and in the end I am forming the complete array with the array aggregator .

Right I can see that - but is the structure of the array aggregator correct for what the email module expects in the attachments mapping area? The error is Array of objects expeced in parameter ‘attachments’ which tells me somehow the array is not exactly correct for what the email module expects to be passed into it.

2 Likes

I didn’t find the correct structure anywhere.

Based on the module structure, I intuited that the structure would be:

[
{
“filename”: “{{Get Variable[1].file1.filename}}”,
“data”: “{{Get Variable[1].file1.data}}”,
},
{
“filename”: “{{Get Variable[2].file2.filename}}”,
“data”: “{{Get Variable[2].file2.data}}”
}
]

Do you know where I could find the correct framework?

The Microsoft 365 Graph API for Outlook I assume.

1 Like

I ended up discovering that it was possible to solve it with Iterator. I didn’t know it was possible to use it for attachments :slight_smile:

Thanks!

2 Likes

Hey there @Democh :wave:

Just wanted to stop by and congratulate you and @alex.newpath for such great cooperation that led to a solution! :clap:

Keep up the good work!

2 Likes

Welcome to the Make community!

Every result (item/record) from an Iterator module will output a bundle. To “combine” them into a single structure, you’ll need to use an aggregator of some sort.

Aggregators are modules that accumulate multiple bundles into one single bundle. An example of a commonly-used aggregator module is the Array aggregator module.

Read this

The Array Aggregator module also allows you to build a complex array of collections for a later module’s field to map multiple items (collections) to it.

Here is an example of using the “Target structure type” of an Array Aggregator module:

As you can see, the “Map” toggle on fields are used when you have an array. You can easily build an array variable to map to a field, by using an Array Aggregator module and select the “Target Structure Type” as the future field you want to map the array into.

samliewrequest private consultation

Join the unofficial Make Discord server to chat with us!