cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper I
Helper I

Send one email to different email addresses based on a condition

Hi,

 

I was able to build a scheduled flow which sends email notification to the "Site Contact" when the signed in visitor hasn't signed out yet (or if Actual Departure date is 'blank') and if the Estimated Departure date is less than today's date.

 

Capture.JPG

 

Currently, my flow may send multiple emails to a single person if there are more than one visitor signed in with the same "Site Contact".

 

What I wanted to achieve is to just send one email to the relevant Site Contacts, where the name of the visitors are listed in a table, instead of them receiving individual emails per visitors' name..

 

From the image above, Site Contact Name A should receive a notification for Gemma while Site Contact Name B should receive a notification for both Mariam and Hayley.

 

I hope someone can help me here! Thanks!

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

 

Hi @KMagadia ,

 

In addition to determining whether the Table is empty, you can determine whether the HtmlTable variable is empty. If it is not empty, then send the message.

22.PNG

 

Best Regards,

Community Support Team _ Barry
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

7 REPLIES 7
Community Support
Community Support

 

Hi @KMagadia ,

 

Assuming the type of the SiteContact field is Person, you can refer to the following methods to achieve your needs.

We need to group according to the SiteContact, and then send the eligible items to the corresponding Site contact.

 

  • Initialize two variables, one to store the emails of all sitecontacts, and the other to store the data to be displayed in the HTML table.
  • Iterate over the value of Get items and append the email of SiteContact to the array variable.
  • Use the union() function to remove duplicate emails and iterate through those emails.
  • Find the eligible items according to email, and append the fields that need to be displayed in the table to the array variable.
  • Create an HTML table and send it. Finally, you need to clear the HtmlTable array variable.

Overview:

18.PNG

19.PNG

Details of Apply to each 2:

20.PNG

Details of Apply to each 3:

21.PNG

Please take a try.

 

Best Regards,

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

Hi @v-bacao-msft,

 

I just followed your instructions..

 

A single email has been sent out but it doesn't capture the created HTML table to the email..

 

I am not sure what I missed.

Capture.JPG

 

Capture.JPG

mmmm...

 

 

 

Hi @KMagadia ,

 

First, you need to check if you configured Output in the Body from the Create HTML table action.

You can then check that the results of each step in the Flow run history are as expected.

And make adjustments based on the results.

 

Best Regards,

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

Hi @v-bacao-msft,

 

My assumption is that the condition is incorrect because the "Expression Result" always appear as 'false' even if the entry is expected to satisfy the condition..

Capture.JPG

 

I think we would also need to have an additional check to not send any email if the html table is empty..

 

Hi @KMagadia ,

 

Please check the Details of Apply to each 3 in the screenshot I provided to see if the configuration is as expected.

 

Best Regards,

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

 

Hi @KMagadia ,

 

In addition to determining whether the Table is empty, you can determine whether the HtmlTable variable is empty. If it is not empty, then send the message.

22.PNG

 

Best Regards,

Community Support Team _ Barry
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-bacao-msft,

 

Thank you so much for your help!

 

It looks like working 🙂

 

I'll reach out if I missed any! Again, thanks!

Helpful resources

Announcements
PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Top Solution Authors
Users online (6,448)