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

How to send an email to the owner of the leads created in the last week?

Hi.


So I want to send an email to the owner of the leads on every Tuesday showing him/her the number of leads created as well as the lead topics/name in the last week. 

Is there any way to achieve this? I was thinking of creating scheduled flow in the power automate but I am not sure how to capture the number of leads created by the owner or anything of that sort. 

Any help/suggestions to this is appreciated.

Thank you. 

9 REPLIES 9
Gericom
Resolver II
Resolver II

Hi @jimxmy 

 

it depends on where you will save the leads.

if you will save them in excel you can use 

https://powerusers.microsoft.com/t5/Building-Flows/Send-an-unique-email-from-Excel-file/m-p/936148#M...

 

the concepts stay the same for sp list or excel 

if you have any questions I'm glad to help you 

with kind regards

--------------------------------------------------------------------------

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

 

jimxmy
Frequent Visitor

Hi.

Regarding leads, I want to fetch it from the Dynamics 365 environment. So maybe a CDS connector or a Dataverse one would be good to go?

Also, not sure how to filter through the last 7 days of the listed records that I'd be able to fetch from the connector. 

Thanks. 

Gericom
Resolver II
Resolver II

hi you can use created on addDays(utcNow(),-7)

 

if you have any questions I'm glad to help you 

with kind regards

--------------------------------------------------------------------------

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

jimxmy
Frequent Visitor

@Gericom @ChrisPiasecki 

Hi.

I have created a scheduled flow for the same but somehow it is in the infinite loop while in 'send an email' action.

Here is my flow:

 email1.PNG

 

 

email2.PNG

Hi @jimxmy,

 

You should use the Dataverse connector and List Rows action. You can specify a filter query of:

createdon ge addDays(utcNow(),-7)

 

---
Please click Accept as Solution if my post answered your question. This will help others find solutions to similar questions. If you like my post and/or find it helpful, please consider giving it a Thumbs Up.

 

@ChrisPiasecki 
Hi, I tried with dataverse as well but the flow is getting stuck on the last step of sending the email as I have shown in the flow. Something is missing here and I am lost. 

 

If by an example, you could show how it could be done, would be greatly appreciated.

Thanks anyways. 

Hi @jimxmy,

 

Perhaps there is a connection issue with the Email connector you are using? Can you try a different flow with just that Send Email Notification action and confirm if it works on its own?

 

---
Please click Accept as Solution if my post answered your question. This will help others find solutions to similar questions. If you like my post and/or find it helpful, please consider giving it a Thumbs Up. 

@ChrisPiasecki 

The connector works fine, I am guessing the conditions are wrong. How to actually split the details of leads by topic and owner and then group them by their owner so that I can create an HTML table for the same for every owner group?

Also, the sending email part would be tricky because I'd be needing to put in the internal email address from the users entity. 
I have been able to get single leads details but I want them in group for the situation if someone has more than one leads created in the last seven days.
Any take on to this complex issue? 

Thanks.

Hi @jimxmy,

 

You can try the following:

 

1. Get all leads from last 7 days. You can use an expand query to get the owning user's email address.

ChrisPiasecki_0-1623622567135.png

 

2. Use a Select action to create a new array that has just your owning user id and email address. Then add a Compose action to get your distinct list of users with leads using the union expression.

ChrisPiasecki_1-1623622858314.png

 

3. Save and test your flow, then copy the output from the Compose action, then edit the flow and add a Parse JSON action to generate a schema so you can reference the fields in your array in following steps.

4. Add an apply to each step to loop over your distinct set of users.

5. Add a filter array action to filter your list of retrieved leads based on the current distinct user in your loop.

ChrisPiasecki_2-1623623051434.png

 

6. Save and test your flow. Inspect the filter array output and take note of the column names you want to include in your HTML table next as you will reference them via expressions.

7. Edit your flow and add a Create HTML Table step. Use custom so you can just pick which columns you want from your filtered list of leads. Use the expression to reference your columns you took note of in previous step (e.g. item()['fullname'])

ChrisPiasecki_4-1623623361729.png

 

8. Finally you can add a send email step where you can add in your HTML table into the body, and you should have the recipients email from the apply to each item.

 

Hope this helps.

---
Please click Accept as Solution if my post answered your question. This will help others find solutions to similar questions. If you like my post and/or find it helpful, please consider giving it a Thumbs Up.

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 (3,245)