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

Send email to specific person if date matches

Hello,

 

I am looking to build a flow and not sure where to start. I'm a novice when it comes to coding/flows.

 

I have an excel sheet that contains a dates. I have simplified it to where the flow would only have to scan and match one column with the current date and send an email to a corresponding person.

 

In clarity - If Cell A1 equals Today, then Send email to cell B1. The flow would check daily.

 

Thank you in advance, you guys have been great so far.

1 ACCEPTED SOLUTION

Accepted Solutions
Heartholme
Super User
Super User

Hi @zw2348 ,

 

Please try this:

Heartholme_0-1652126065913.png

1. Daily reccurance

2. List rows present in table

3. Then make a condition and add the A column in the first condition, this will automatically make an apply to each.

4. Then make the current expressions:

The date from your excel sheet: formatDateTime(items('apply_to_each')?['ACOLUMN'],'yyyy/MM/dd')

The date today: formatDateTime(utcnow(),'yyyy/MM/dd')

5. If yes, then send an email to the B column value like this (I just used the compose in the above picture to verify that it was working, it can be a nice step to do for you as well)

Heartholme_1-1652126219570.png

Let me know how it goes 😊

 

{ Please click Accept as solution ✔ if my post answered your question. }
{ This will in turn help others find solutions to similar questions. }

Best Regards
Heartholme

 

 

View solution in original post

11 REPLIES 11
Heartholme
Super User
Super User

Hi @zw2348 ,

 

Please try this:

Heartholme_0-1652126065913.png

1. Daily reccurance

2. List rows present in table

3. Then make a condition and add the A column in the first condition, this will automatically make an apply to each.

4. Then make the current expressions:

The date from your excel sheet: formatDateTime(items('apply_to_each')?['ACOLUMN'],'yyyy/MM/dd')

The date today: formatDateTime(utcnow(),'yyyy/MM/dd')

5. If yes, then send an email to the B column value like this (I just used the compose in the above picture to verify that it was working, it can be a nice step to do for you as well)

Heartholme_1-1652126219570.png

Let me know how it goes 😊

 

{ Please click Accept as solution ✔ if my post answered your question. }
{ This will in turn help others find solutions to similar questions. }

Best Regards
Heartholme

 

 

zw2348
Frequent Visitor

Thank you so much for the reply. I am having major brain farts today, in the expression for formating the dates to compare it has to reference to today's date. The solution has 'ColumnA', in my sheet its named Due Date. So that I don't get an error, I need to rename this in the forumla to 'Due Date', correct?

 

In the flow the Compose line - what goes there? Below is what I have currently. Thank you for all your support. 

zw2348_0-1652129094858.png

 

Happy to help! Yes, rename this to 'due date'. You might have to use 'due_date' because of the space.

 

In the compose I just put the 2nd column, with the email, but you can skip this and add it directly into the send email action.

 

Let me know how it goes 😊

 

zw2348
Frequent Visitor

Well I did something wrong, it came back with the following error. 

 

Unable to process template language expressions for action 'Condition' at line '0' and column '0': 'The template language function 'formatDateTime' expects its first parameter to be of type string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#formatdatetime for usage details.'.

 

Oh what.. I had it as Due_Date and it like Due Date.. this is solved. You're the best!

Heartholme
Super User
Super User

@zw2348 

 

Perfect. Glad to hear 😄

 

My bad on the Due_Date, on some queries it's needed when dealing with spaces, in variables/outputs and such. Could'nt remember how it was for excel.

zw2348
Frequent Visitor

Okay, can I bug you for one more solution.. the flow ran yesterday, as I received an email. The flow seems to fail due to not every cell having a date listed, or I think. I'm getting the following error.. 

 

Unable to process template language expressions for action 'Condition' at line '0' and column '0': 'In function 'formatDateTime', the value provided for date time string '' was not valid. The datetime string must match ISO 8601 format.'.

 

I have the table for both dates as yyyy/MM/dd in the excel sheet. Could this be failing due to blanks? 

 

zw2348_0-1652202105118.png

zw2348_1-1652202138800.png

 

 

Heartholme
Super User
Super User

Hi @zw2348 ,

 

Sure, no problem!

You could try to filter these out in the filter query, check out this:

https://tomriha.com/remove-excel-rows-with-empty-value-with-power-automate/

 

Or you could have a condition to filter out blank reponses with something along these lines:

https://powerusers.microsoft.com/t5/General-Power-Automate/skip-blank-column/td-p/120516

 

I don't have time to go into more detail right now, but can look at later if you still run into issues here 😊

zw2348
Frequent Visitor

I am lost.. again :).

 

I have the flow working all the way up to formatting the date to match today's date. If I am reading the formula correctly, it looks like its not finding the column in the table. I removed the space so the column name is 'DueDate'.

 

Edited formula: formatDateTime(items('apply_to_each')?['DueDate'],'yyyy/MM/dd')

 

Error "

InvalidTemplate. Unable to process template language expressions for action 'Condition_2' at line '0' and column '0': 'In function 'formatDateTime', the value provided for date time string '43258' was not valid. The datetime string must match ISO 8601 format.'."

 

zw2348_0-1652287277580.png

zw2348_1-1652287312695.png

 

Seems like the condition/reformatting dosen't work on blank cells.

 

Try this:

 

1. if(equals(formatDateTime(items('apply_to_each')?['DueDate'],'yyyy/MM/dd'), ''), 1998/02/02, formatDateTime(items('apply_to_each')?['DueDate'],'yyyy/MM/dd'))

 

or this:

 

2. if(equals(items('apply_to_each')?['DueDate'], ''), 1998/02/02, formatDateTime(items('apply_to_each')?['DueDate'],'yyyy/MM/dd'))

 

Can't remember if '' is the value of blank cells, but I guess if there is a "blank" value from the excel cell output, put it between the '' in the expression.

 

Hopefully this solve every case.

 

Did you try this for the list rows present in table?

 

Heartholme_0-1652300846997.png

 

That should remove the blanks.

 

Br

Heartholme

zw2348
Frequent Visitor

Finally figured it out.. I rebuilt the flow and tinkered with the excel sheet and it finally works! Part of the issue seemed to be the excel sheet wasn't in the text for formating. Thank you for all your support, I have 2 small things to add but I'm waiting for IT to add me to a mailbox 🙂

Heartholme
Super User
Super User

@zw2348 Great! 😄 Yes, working with excel can be a bit frustrating at times, since there are a lot of details which can cause errors. 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (5,433)