cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Merel
Advocate II
Advocate II

Multiple list items in one mail, but one mail per person

Hi all,

 

I'm trying to build a flow that sends recurring reminders to people of open list items. So, what it needs to do is:

 

  • Filter items in a list to open items
  • Send 1 mail with all items that have been assigned to person A and 1 mail with items that have been assigned to person B to these respective persons.

What I've managed to build is a flow that filters and sends only 1 mail, but the mail is send to everybody that appears in the 'assigned to' column. So basically everybody that has a list item assigned to them receives a list with all open list items, also the ones that are assigned to other people.

 

This is what I've done:

 

1.PNG2.png

 

3.PNG4.PNG

 

Thanks in advance for any help!

 

Merel

 

 

 

 

 

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
v-yamao-msft
Community Support
Community Support

Hi @Merel ,

 

Do you want to send emails to people with items assigned to them separately?

 

Please check if the following configuration will be a reference for you.

 

Initialize an Array variable named as Test.

 

Get items from the list using Filter Query Status eq ‘Approve’.

 

Add Apply to each, select Value from Get items, within the apply to each loop add action Append to array variable, select dynamic content Assigned Email for the Value field.

 

Add Compose action with the following function:

union(variables('test'),variables('test'))

 

Add Apply to each to, select output from the Compose output.

 

Within the loop, add action Filter array, select Value from Get items action, set its condition to:

Assigned Email is equal to Current Item (of Apply to each 2)

 

Add action Create HTML table, select Body from Filter array. Here I customize Title and assigned field using the following functions:

 

Title: item()?['Title']

Assigned: item()?['Assigned']?['Email']

 

Add action Send an email. Select HTML output for the body field, and enable Yes for the Is HTML field.

1.PNG2.PNG3.PNG

 

Best regards,

Mabel  

 

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi @Merel ,

 

In the action Create HTML table, you should select Body from Filter array but not select Value from the action Get items.

 

Please check the screenshot I provided in my previous post and try again with it.

 

Best regards,

Mabel

 

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

18 REPLIES 18
v-yamao-msft
Community Support
Community Support

Hi @Merel ,

 

Do you want to send emails to people with items assigned to them separately?

 

Please check if the following configuration will be a reference for you.

 

Initialize an Array variable named as Test.

 

Get items from the list using Filter Query Status eq ‘Approve’.

 

Add Apply to each, select Value from Get items, within the apply to each loop add action Append to array variable, select dynamic content Assigned Email for the Value field.

 

Add Compose action with the following function:

union(variables('test'),variables('test'))

 

Add Apply to each to, select output from the Compose output.

 

Within the loop, add action Filter array, select Value from Get items action, set its condition to:

Assigned Email is equal to Current Item (of Apply to each 2)

 

Add action Create HTML table, select Body from Filter array. Here I customize Title and assigned field using the following functions:

 

Title: item()?['Title']

Assigned: item()?['Assigned']?['Email']

 

Add action Send an email. Select HTML output for the body field, and enable Yes for the Is HTML field.

1.PNG2.PNG3.PNG

 

Best regards,

Mabel  

 

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi @v-yamao-msft ,

 

Thanks for your superswift reply!

 

Indeed what you're describing is what I want to do. When I try your solution however, the Create HTML automatically turns into an 'apply to each' loop. In my test setup I have 3 items from the list that should be emailed to me. When testing this solution,  I receive 3 emails with 3 rows of the same item. So email one contains 3 rows with item A, email 2 contains 3 rows with item B, email 3 contains 3 rows with item C.

 

5.PNG

 

Any ideas why this is?

 

Thanks again!

 

Merel

 

 

Hi @Merel ,

 

In the action Create HTML table, you should select Body from Filter array but not select Value from the action Get items.

 

Please check the screenshot I provided in my previous post and try again with it.

 

Best regards,

Mabel

 

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi @v-yamao-msft ,

 

I now see what you mean and it works perfectly! Thank you so much!

 

Merel

Hi @v-yamao-msft   great information is just what I was looking for 🙂

 

Is it possible to get the number of items each person will receive in the email? I would like to include on the subject of the email sent the number of items related to that person. 

 

Thank you in advance!

This solution works really fine. Thanks for that. I have a short question: When I change Recurrence into When a new SharePoint List item is added, the flow sends the emails as much as rows are according to the user. Does anybody know, what I have to change? Thanks

I am getting the following error: Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The inputs of template action 'Filter_array' at line '1 and column '1913' is invalid. Action 'Apply_to_each' must be a parent 'foreach' scope of action 'Filter_array' to be referenced by 'repeatItems' or 'items' functions.'.'.

ikapsmoi
Regular Visitor

The execution of template action 'Apply_to_each_2' failed: the result of the evaluation of 'foreach' expression '@outputs('Compose')' is of type 'String'. The result must be a valid array.

 

Please assist boss 

@v-yamao-msft 

ikapsmoi
Regular Visitor

My error snapshot community, please check and advise where did i go wrong with compose 

ikapsmoi_0-1620303169345.png

 

ikapsmoi
Regular Visitor

By reading this post again and again i have solved the previous problem, however new issue i am getting the same email equal to the number of items on my name

Hi Mabel,

 

I followed your flow exactly, but it still sends as many emails as items are created in SQL for each email. 

Dan14_0-1622718675080.png

 

Dan14_1-1622718748944.pngDan14_2-1622718798508.pngDan14_3-1622718837527.pngDan14_4-1622718878171.png

Any help is highly appreciated.

 

Thank you!

Dan

Same here. Did you find a workaround for that?

 

Thank you!

Dan

ikapsmoi
Regular Visitor

s

ikapsmoi
Regular Visitor

Hi Dan, 

 

problem is with your create HTML table at first, you have straight away added values from dynamic content, however you have to use the expression dynamic content section to add each value field. 

 

Example: If you want to add Title from your list = Click on Dynamic content - than Expression and add title in this manner - 

item()?['Title']

and so forth for all the other value fields. 

 

Hope this works

Thank you for the quick reply. Yes, i have already created the html table using the item expression. This not seems to be the issue.

 

Are you saying that following the steps in this original thread, you were able to send one single email with multiple items assigned to that email address?

 

Thank you,

Dan

 

ikapsmoi
Regular Visitor

Yes, following the suggested steps by @v-yamao-msft my flow is working as expected. 

 

 

Using 'Recurrence' as trigger or 'When an item is created'? For me it's not working with 'When an item is created' trigger.

 

Thank you!

ikapsmoi
Regular Visitor

Haven't tried with Item is created - mine is recurrence

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Users online (22,713)