cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Marika21
Frequent Visitor

Sending emails

Hi, 

 

I have a flow created to send reminding email after 1 day but I want to send this email only to specific clients from the MS List.

When I´m trying to add a condition it automatically changed to apply to each and even if I add a condition to only sends an email if the client name is equal to ... it sends an email to all. Not sure what I`m doing wrong 

 

Capture.JPG

 

Thank you! 

1 ACCEPTED SOLUTION

Accepted Solutions
manuelstgomes
Super User
Super User

HI @Marika21 

 

The "Get items" will always return an array, even if you're defining from the start that you'll get only one person. The "Get items" will return an array of 1 but still an array and not an object.

 

When you reference it in the condition, an "Apply to each" is generated because it's an array. You can leave it like that because you're sure that you're always getting only one record.

 

There's also the possibility to extract only the first element (in this case, the only one). We can define a formula to do that, but we need to be careful because the array may be empty for some reason.

Screenshot 2021-03-30 at 11.37.33.png

 

Here's the formula:

if(greaterOrEquals(length(outputs('Get_items')?['body/value']),1),outputs('Get_items')?['body/value'][0],'')

 

Can you please check if and let me know if you have any questions?

 

Cheers
Manuel

-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

4 REPLIES 4
DamoBird365
Super User
Super User

Hi @Marika21 

 

Do your get items return 1 item or many items with emails that you want to email to?

 

If it's many, you will need to create a string of those emails prior to sending the email.  The easiest way to do this is use the select action.

 

Put the values as the input for the select action and then choose the advance mode.  Enter the dynamic value for email into the editor.  You now have an array of emails.

 

With a compose action you can then use the Join expression on the select array using a semi colon.  Join('selectarray',';')

 

You will then not need an apply to each and can simply use the compose in your email action.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here

manuelstgomes
Super User
Super User

HI @Marika21 

 

The "Get items" will always return an array, even if you're defining from the start that you'll get only one person. The "Get items" will return an array of 1 but still an array and not an object.

 

When you reference it in the condition, an "Apply to each" is generated because it's an array. You can leave it like that because you're sure that you're always getting only one record.

 

There's also the possibility to extract only the first element (in this case, the only one). We can define a formula to do that, but we need to be careful because the array may be empty for some reason.

Screenshot 2021-03-30 at 11.37.33.png

 

Here's the formula:

if(greaterOrEquals(length(outputs('Get_items')?['body/value']),1),outputs('Get_items')?['body/value'][0],'')

 

Can you please check if and let me know if you have any questions?

 

Cheers
Manuel

-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

DamoBird365
Super User
Super User

Hi @Marika21 

 

You'll see that there are two options depending on what you are trying to achieve.  If you want to retrieve the first email of the first item retrieved by get items, use @manuelstgomes solution.  If you want to merge all emails returned by all items in your get items use my answer.

 

DamoBird365_0-1617101822148.png

 

Here is the result:

DamoBird365_0-1617101959385.png

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here

Marika21
Frequent Visitor

Thank you it actually started to work and I did not have to change anything as you said @manuelstgomes 

I added few parallel branches to that flow and is working perfectly 🙂

 

 

thank you for new ideas @DamoBird365 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (1,236)