cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Care
Level: Powered On

Use FLOW to loop through table and send email

I have had a quick 1 hour introduction to PowerApps and I woul like to know if this is possible with FLOW.

I would like a flow that would fire every Every Monday morning and loop through my SQL vendor table and get all OPEN PO's 
I would then like to send 1 email to each vendor that has an open PO.
In My example
PlainVendor would get an email and that email would list 2 PO's on it. One for PO PL85R and one for PO DOG56
HappyVendor Would get an email with PO SAM78 on it
OldVendor Would not get an email because they have no open PO's    

 

Is this posible with PowerApps FLOW?
   Thank You So Much

VendorPOStatusVendorNameVendor Email
456ZX85BClosedHappyVendorHappyVendor@email.com
AB7PL85ROpenPlainVendorPlain@email.com
AB7DOG56OpenPlainVendorPlain@email.com
456SAM78OpenHappyVendorHappyVendor@email.com
967FROG1ClosedOldVendorOld@email.com
9 REPLIES 9
cwebb365
Level 10

Re: Use FLOW to loop through table and send email

Yes. It’s late and I’m in bed so I can’t give much details but you can use sql connector in flow to query the data you need to get all the vendors emails that have a matching criteria and in that loop. You can put another query to get the items where the email is equal to the email on that run of the loop. And use those POs into an html table etc. and then send the email with that table. Then that loop goes for next email does same thing.

That’s the really high level version but yes it can be done ;). I have an example I use that I can post up tomorrow if you haven’t figured it out by then. Just shoot me a reply here so I have an email to follow up on if so.
Care
Level: Powered On

Re: Use FLOW to loop through table and send email


Any and ALL help is welcome. 

As I said I am new to PowwerApps and greatly appreciate the help.

 

Thank You So Much

@cwebb365 wrote:
Yes. It’s late and I’m in bed so I can’t give much details but you can use sql connector in flow to query the data you need to get all the vendors emails that have a matching criteria and in that loop. You can put another query to get the items where the email is equal to the email on that run of the loop. And use those POs into an html table etc. and then send the email with that table. Then that loop goes for next email does same thing.

That’s the really high level version but yes it can be done ;). I have an example I use that I can post up tomorrow if you haven’t figured it out by then. Just shoot me a reply here so I have an email to follow up on if so.

 

Highlighted
cwebb365
Level 10

Re: Use FLOW to loop through table and send email

Here is a snip of a flow I have that basically does the same thing. It uses a stored Proceedure to return a list of e-mail address of users/sites that are not compliant (no reading for the day), the loops through that list, sending each area manager a list of sites in their area missing readings. Hope this helps. 

 

poflow.JPG

Community Support Team
Community Support Team

Re: Use FLOW to loop through table and send email

Hi @Care ,

 

Have your problem been solved refer to @cwebb365 's solution?

If yes, please go ahead and mark the post as solved by clicking “Accept as Solution” so that this thread will be marked for other users to easily identify!

If no, please let me know and I would provide a proper workaround for you.

 

Best regards,

Alice       

 

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

Care
Level: Powered On

Re: Use FLOW to loop through table and send email

I apologize I am Just getting back to this

I am stuck on the very first part of the Loop.

How do I get a "Results Set Table"  in there?

I am including my "GET" stored Procedure also. If you would please tell me if this is written correctly.

Thank You

USE [Sandbox]
GO
/****** Object:  StoredProcedure [dbo].[GetPurchaseOrderEmails]    Script Date: 9/23/2019 1:36:55 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[GetPurchaseOrderEmails] 
@VendorEmail varchar(50) OUTPUT 
AS
SET NOCOUNT ON;  
SELECT [VendorEmail]
  FROM [Sandbox].[dbo].[Destination]
  where PurchaseStatusDescription <> 'Closed'
  
 return

GO
Care
Level: Powered On

Re: Use FLOW to loop through table and send email

I apologize I am Just getting back to this

I am stuck on the very first part of the Loop.

How do I get a "Results Set Table"  in there?


@cwebb365 wrote:

Here is a snip of a flow I have that basically does the same thing. It uses a stored Proceedure to return a list of e-mail address of users/sites that are not compliant (no reading for the day), the loops through that list, sending each area manager a list of sites in their area missing readings. Hope this helps. 

 

poflow.JPG


Thank You

cwebb365
Level 10

Re: Use FLOW to loop through table and send email

You take the results from the stored proceedure run,  and put it in one of your steps, such as e-mail, or another SP and it will then loop based on that value. 

 

In my example, i use a SP to get e-mail addresses of people needing an alert. Then I have another execute SP where I use the e-mail results from the first SP, this then creates a loop, which I then use the results from the 2nd SP in the HTML table to build out the e-mail body info. 

Care
Level: Powered On

Re: Use FLOW to loop through table and send email

Thank You so much for all of your help. Would you mind looking at my first SP.  Did I do it right?  It is getting all email addresses that have open po's?

Also  would you mind sharing your execute SP with me?  I could not find anything on  creating an Execute SP. 

USE [Sandbox]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[GetPurchaseOrderEmails] 
@VendorEmail varchar(50) OUTPUT 
AS
SET NOCOUNT ON;  
SELECT [VendorEmail]
  FROM [Sandbox].[dbo].[Destination]
  where PurchaseStatusDescription <> 'Closed'
  
 return


GO
cwebb365
Level 10

Re: Use FLOW to loop through table and send email

My 2nd stored proc is just a stored proc that has an input, which I use that e-mail input in my select statement, so that each time that loop runs it passes the current e-mail address, and then I use that output for my table. So whatever columns you need for your e-mail you would have in your select and the @input would be e-mail address.

Once you have this other SP, you use the Output from the first SP in this case email, in the 2nd SP's input and flow will automatically add the loop in. Then use the 2nd SP's outputs in your HTML table / e-mail.

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Speakers, submit your sessions now! Call for speakers ends Feb. 10!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,688)