1

I have a flow, whose final step is to send an email. The attachments field/-s can be populated by specifying individual attachments, or by specifying an array of variables (in case the number of attachments cannot be known in advance). I am curious if I can achieve both - attach an array of variables along with individually specified attachments?

The reason why the individual attachments cannot go into the array is that they are of a different nature, and their source is also different. In my case, the individual attachments are word templates that have been filled at previous steps in the flow, while the array of attachments are pictures; these are taken from an SharePoint list, from its Attachments column, which in turn originated from the submission of Power Apps application.

Below is the kind of thing that I try to achieve: sort of appending an array of variables to already existing attachment items. Either of them (the individual items, or the array of variables) work OK, but they cannot go together, or at least, not the way I did it.

enter image description here

3
  • attachments variable (array of variables) also have same properties (Name & ContentBytes)? Or do they have any additional/different properties? Aug 7 at 8:58
  • Yes. They do have a Name and a ContentBytes property Aug 7 at 10:04
  • Then you can create 2 arrays and then combine them. Then pass combined result to send an email - attachments action. Aug 7 at 10:12

1 Answer 1

0

If your attachments variable ("array of variables" in your screenshot) also have exact same properties (Name & ContentBytes), then follow below steps:

  1. Create another array for your "individual attachments"
  2. Combine both arrays together using union() function
  3. Use output of union in send an email - attachments action

Example: I am showing you how to create two array variables and combine them together - you can use similar logic for your requirements:

Here's the complete flow:

enter image description here

Expression used in "Compose" action:

@{union(variables('varArray1'),variables('varArray2'))}

Output:

enter image description here

4
  • I followed this approach. Unfortunately, the flow failed. Earlier today, I tried a similar approach, by appending the individual items (which are word documents) to the array variable. The error message was the same : "OpenApiOperationParameterValidationFailed. The 'inputs.parameters' of workflow operation 'Send_an_email_(V2)' of type 'OpenApiConnection' is not valid. Error details: The API operation 'SendEmailV2' is missing required property 'emailMessage/Attachments/1/Name'." Aug 7 at 11:56
  • That means one of the array element (object) does not have required property named as "Name" - for file name.. Aug 7 at 11:57
  • 1
    In the step "append to array variable", in the Value section, I initially took the easy approach of just adding the Microsoft Word tag that corresponded to the output of one of the above steps. Instead, I should have opened curly brackets, and create an object with Name and ContentBytes properties. (The value of the ContentBytes property is that Microsoft Word tag. ) Now it works ! Aug 7 at 12:25
  • 1
    Thanks for the time invested in elaborating this answer. This really saved my day ! Aug 7 at 12:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.