Send Multiple Attachments - Microsoft 365 Email (Outlook) / Create and Send a Message

I need to send multiple e-mails, but I do not know how to structure the Attachments field when using the Map.

Any ideas, please?

Hey there,

most likely your array is not structured in the same way that the module is expecting. Its expecting the names of the variables to be “filename” and “data” and it looks like you are sending it an array with “name” and “content” instead.

Thanks for your time, @Stoyan_Vatov!

I’ve already tried your suggestion and small variations but the problem persists.

I’ve tried to look at Microsoft’s documentation (Add attachment - Microsoft Graph v1.0 | Microsoft Learn) but it doesn’t work either.

You do NOT need a Parse JSON module. See “Mapping a Specific Structure Into a Complex Field” below.

Combining Bundles Using Aggregators

Every result (item/record) from trigger/iterator/list/search/match modules will output a bundle. This can result in multiple bundles, which then trigger multiple operations in future modules (one operation per bundle). To “combine” multiple bundles into a single variable, 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. The next popular aggregator is the Text Aggregator which is very flexible and can apply to many use-cases like building of JSON, CSV, HTML.

You can find out more about the other types of aggregator modules here:

Mapping a Specific Structure Into a Complex Field

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

This is done using the “Target structure type” field in an Array Aggregator module.

Here is an example:

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

Example

Here is an example of how your scenario could look:

This is just an example. Your final solution may or may not look like this depending on your requirements.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

Hi, @samliew. Sorry for not replying previously, but we had our biggest holiday in Brazil (Carnaval).

I appreciate the detailed explanation you provided. I’ve just tested and it works perfectly!

However, I still need to add another file to the Attachments field that is unrelated to the iteration. Take a look at the image below, please:

To give you some context, I want to send an invoice and all the accounts receivable related to the same invoice. The relation between invoice and account receivable is 1 to N.

The iterator with the array aggregator is wrapping the accounts receivable. Now I need to download the invoice and send it as an attachment with the accounts receivable.

I’ve tried to use another iterator and array aggregator, filtering for just the first Bundle order position, but received the same error as before when using the add function to combine both array aggregators.

Any suggestions?

Instead of “add”, since you have two arrays, you can use the built-in function merge.

e.g.:

{{ merge(5.array; 16.array) }}

For more information, see Array functions page in the Make Help Centre, which covers the following:

  • add (array; value1; value2; …)
  • contains (array; value)
  • deduplicate (array)
  • distinct (array; [key])
  • first (array)
  • flatten (array)
  • join (array; separator)
  • keys (object)
  • last (array)
  • length (array)
  • map (complex array; key;[key for filtering];[possible values for filtering separated by a comma])
  • merge (array1; array2; …)
  • remove (array; value1; value2; …)
  • reverse (array)
  • shuffle (array)
  • slice (array; start; [end])
  • sort (array; [order]; [key])
  • toArray (collection)
  • toCollection (array; key; value)

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.