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
Community Champion
Community Champion

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
Community Champion
Community Champion

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.

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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (2,264)