cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Delaying sending emails

I have two flows that send emails, one when a PowerApps app adds an item to a SharePoint list and the other goes "for each" down the list and send an email to those that match a filter.

 

What I am now trying to do is, if the flow is triggered between 8pm and 8am, delay sending the email until after 8am.

 

I am assuming I need some combination of getting "current time" from date-time connector,  and "do until" along with "wait"  but can't sort the details of how to test the time and set up the wait.

 

Any help appreciated

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Delaying sending emails

Hi @PhilipGoodfello,

 

I have a method here that you could refer to, although I think there will be a better way, but I hope to give you some tips.

Use Compose action to store the Hours part of the three time periods in a string value.

Then determine if the current time is within these three time periods.

If the current time is at 8pm-8am, you also need to determine if the time is on the previous day or the next day, which will affect the setting of Timestamp behind Delay until.

If the time period is 8pm-00am, you need to delay sending mail to 8:00 the next day.

Image reference:

21.PNG

Delay until:  formatDateTime(addDays(body('Current_time'),1),'yyyy-MM-ddT08:mmZ')

Delay until2: formatDateTime(body('Current_time'),'yyyy-MM-ddT08:mmZ')

20.PNG

Please take a try.

 

Best Regards,

Barry

 

 

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

View solution in original post

7 REPLIES 7
Highlighted
Community Support
Community Support

Re: Delaying sending emails

Hi @PhilipGoodfello,

 

I have a method here that you could refer to, although I think there will be a better way, but I hope to give you some tips.

Use Compose action to store the Hours part of the three time periods in a string value.

Then determine if the current time is within these three time periods.

If the current time is at 8pm-8am, you also need to determine if the time is on the previous day or the next day, which will affect the setting of Timestamp behind Delay until.

If the time period is 8pm-00am, you need to delay sending mail to 8:00 the next day.

Image reference:

21.PNG

Delay until:  formatDateTime(addDays(body('Current_time'),1),'yyyy-MM-ddT08:mmZ')

Delay until2: formatDateTime(body('Current_time'),'yyyy-MM-ddT08:mmZ')

20.PNG

Please take a try.

 

Best Regards,

Barry

 

 

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

View solution in original post

Highlighted
Helper II
Helper II

Re: Delaying sending emails

Thank you. That is definitely getting me on track. I think I also need to add localisation to the time somewhere (convert time zone?).  I am in UK so the current time in UTC will work in the winter but will be an hour out in summer.

Highlighted
Community Support
Community Support

Re: Delaying sending emails

Hi @PhilipGoodfello.

 

Yes, you can use covert time zone.

Or put an addHours() function on the outside of all "body('Current_time')" with the parameter '1' or '-1'.

Like: addHours(body(‘Current_time’)),1)

Please take a try and see if this is the effect you expected.

 

Best Regards,

Barry

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

Re: Delaying sending emails

I have been giving your suggestion a try but am getting an error in "Delay 2".  Any pointers where to look to sort this out would be appreciated. I am new to Flow's of any complexity.

DEA70988-8944-4224-9405-EB60B0121DB2.jpeg

 9B30DAFF-55FF-465B-9E83-AA68C5049A73.png

Highlighted
Community Support
Community Support

Re: Delaying sending emails

Hi @PhilipGoodfello,

 

Please configure the formula in Expression, and Delay until/Delay until2 need to do this.

29.PNG

Take a try again.

 

Regards,

Barry

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

Re: Delaying sending emails

Thank you for your help.

 

After inserting an Expression in the Delay Until cards the flow is now running without failures.

The correct branch is being taken at the conditions at the right times of day.

However, even when the flow clearly branches through the Delay Until card the delay is not actually happening and the emails is sent immediately. 

 

I am assuming I need to debug the logic in the Delay Until expression.  Is there a way to get "inside" to see what value for time is actually passed back to the card?

 

 

 

Highlighted
Helper II
Helper II

Re: Delaying sending emails

Thank you for your help.  Your suggestions have essentially been the basis of my, now working, solution.

 

The main tweaks required were:

In the first condition:

FormatDateTime(body('Current_time'),"hh") should be FormatDateTime(body('Current_time'),"HH") to give 24h clock to compare with the values 08 to 19 for 8am to 8pm.

 

The "send an email" card is only required once - it can come outside all the conditions right at the end.  It is only triggered after the delay (if any) for the relevant condition branch has been actioned.

 

Helpful resources

Announcements
Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Top Solution Authors
Top Kudoed Authors
Users online (4,787)