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

Weekly Calendar Digest keeps sending duplicate emails

Hello all,

 

I have put together a Flow to look at my Outlook calendar each week, and send a weekly digest email for upcoming events. The flow compiles details from upcoming calendar events into an HTML table, then sends them out in an email. I don't want the email to send unless there are actually events occurring, so to solve this, I set up a Condition (see below).

 

Problem is, if there are multiple events occuring, the flow will then send the email multiple times. For example, if there are 3 events in the coming week, I will receive 3 identical emails at the scheduled time.

 

How do I get the flow to only send one email, even if there are multiple events?

 

Screen Shot 2019-09-30 at 8.55.27 AM.png

15 REPLIES 15
Super User
Super User

Re: Weekly Calendar Digest keeps sending duplicate emails

@clarapfm 

Hi there.  Rather than checking for an event, can you build your table and then only send it if there is something in it?

Another thing I was thinking was to update a variable if there was a suitable event, and then outside of your Apply to Each loop, check the variable for content and send the table if the variable has something in it.

 

Keep us posted.

-Ed-

 

 

If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

clarapfm
Level: Powered On

Re: Weekly Calendar Digest keeps sending duplicate emails

@edgonzales This is exactly what my current code does. As you can see from my (above) screenshot, the code checks for an event variable (start time), and if there is no valid start time, it does not send the email; if there is, it sends. When there are multiple events, it sends multiple emails. I have tried using "value" or the array I create with the list of events within my condition, and it still spits out multiple emails.

 

Is there another way I can go about this?

Super User
Super User

Re: Weekly Calendar Digest keeps sending duplicate emails

Right, but notice how you are checking the condition inside of an Apply to Each loop?  That means that it is going row by row to check the condition for each row.  So, for an example of 5 events, it's going to check each row and see that the date is not null and then go down the yes path five times.

I am suggesting moving the condition outside of that loop.

 

I am guessing right above this is the step where you build the table, right?  Because your condition is checking something that is event (row) specific, it triggers another loop.  Change the condition to look at the output of the previous step (your table) and only send the email if there is data in it.

 

If you'd like, post a pic of the previous steps and I can help edit.

 

Thanks,

-Ed-

 

clarapfm
Level: Powered On

Re: Weekly Calendar Digest keeps sending duplicate emails

@edgonzales For some reason, when I created the Condition, it was automatically placed inside of an "Apply to each." I just moved the Condition outside and tested - I only received 1 email this time! Thank you so much, problem solved!

clarapfm
Level: Powered On

Re: Weekly Calendar Digest keeps sending duplicate emails

@edgonzales I spoke too soon. Now, the flow sends even if there are no events to speak of.

 

Here is my full flow:

 

Screen Shot 2019-09-30 at 3.13.02 PM.pngScreen Shot 2019-09-30 at 3.12.05 PM.pngScreen Shot 2019-09-30 at 3.11.51 PM.pngScreen Shot 2019-09-30 at 3.12.45 PM.png

Super User
Super User

Re: Weekly Calendar Digest keeps sending duplicate emails

Perfect.  Change your condition so that instead of "Value" it shows the variable "EventLists", but is still checking for null.  And, I think if it is null, you can probably just end the Flow, right?  Then it will just run again the following week?  Or did you want it to try again sooner?

 

Keep at it, you're almost there!

-Ed-

 

 

If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

clarapfm
Level: Powered On

Re: Weekly Calendar Digest keeps sending duplicate emails

@edgonzales I tried exactly as you said, and tested twice:

  1. Using a calendar with several upcoming events -- Only received one email, with all upcoming data (exactly what I was hoping for)
  2. Using calendar without upcoming events -- Received an email (I was not supposed to receive an email

 

Looks like the condition isn't working.

 

What command do I use to stop the flow, without turning it off? This is a scheduled flow, so I don't want the flow to turn itself off if there are no upcoming events. I need it to continue to check for events every week.

Super User
Super User

Re: Weekly Calendar Digest keeps sending duplicate emails

Post a pic of the updated condition, let's take a look.

clarapfm
Level: Powered On

Re: Weekly Calendar Digest keeps sending duplicate emails

@edgonzales Here's what it looks like now (I changed it from "value" to my "EventLists" array):

 

Screen Shot 2019-09-30 at 4.33.28 PM.png

Super User
Super User

Re: Weekly Calendar Digest keeps sending duplicate emails

Ok, I think I've got it.  The condition is working, I just missed something.

So, inside your loop, you are appending some code to the variable.  It looks like this:

 

{

 "Description": <subject>,

 "Details": <content"

}

 

So even if there is no event, your variable will always have "Description" and "Details" in it and therefore NOT be null...ever.

 

So we need to find another way to filter.  I know there's an expression like "isblank" or something like that, but I'm not great with those.  Here's my idea:

 

  1. In addition to the variable "EventLists", initialize another array variable at the beginning called "EventCheck" or whatever you want.
  2. Inside your "Apply to Each" loop, add a step "Append to Array variable" and only append the dynamic field "Subject" or any other field that will have data.  That way, if there are no events, the EventCheck variable will be empty.
  3. Outside of your loop, in your condition field, instead of checking the EventLists variable, check the EventCheck variable.

THEN it should work. 🙂

Sorry for missing that earlier.  Keep us posted.

-Ed-

 

 

If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

clarapfm
Level: Powered On

Re: Weekly Calendar Digest keeps sending duplicate emails

@edgonzales Thanks for the suggestion, and your continued help.

 

Unfortunately, the flow now fails every time I test it. Here are the changes I made:

  • Added a new Initialize variable (called it EventCheck)
  • Added another Append to array variable to look at Start time (I also tried Subject)
  • Updated the condition to look at EventCheck

 

 

Screen Shot 2019-09-30 at 5.43.24 PM.pngScreen Shot 2019-09-30 at 5.43.44 PM.png

Super User
Super User

Re: Weekly Calendar Digest keeps sending duplicate emails

My pleasure...we'll get this.  How is it failing now?  Are you getting an error?

Remember, if it's going down the wrong path, we want to look at the actual data being passed (by looking at previous runs).

 

Keep at it.

-Ed-

 

clarapfm
Level: Powered On

Re: Weekly Calendar Digest keeps sending duplicate emails

@edgonzales I pinpointed it to the "Create HTML table" step. It turns out that step is not compatible with having two "Initialize variable" steps; I ended up having to delete everything from the first "Initialize variable" down, and rebuild the flow without the "EventCheck" variable, in order to get the flow to work again. A shame; your logic was sound and I thought for sure it would work this time!

Community Support Team
Community Support Team

Re: Weekly Calendar Digest keeps sending duplicate emails

Hi @clarapfm ,

 

Have your problem been solved, 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!

 

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.

clarapfm
Level: Powered On

Re: Weekly Calendar Digest keeps sending duplicate emails

@v-alzhan-msft  No, my problem has not been solved. I am still experiencing issues with my flow.

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons in April

Read the announcement for more information!

firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

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!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,757)