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

Scheduled Occurrence Flow- if a date condition is met, attach files from sharepoint list into email

I'm trying to build a flow that will:

1. Every day, look at the expiration date column in a sharepoint list.

2. If the expiration date is equal to today, then send an email (to a contact specified in the SP list) including the attachment that's also in the list.

 

From reading other posts, I think I need to create an attachments array, but Flow won't let me Get Items and Get Attachments/Initialize Variable.

 

This is my flow so far. It works, but I just can't get the attachment to be included in the email:


flow 1.PNGflow 2.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
v-yamao-msft
Community Support
Community Support

Hi @chanafee ,

 

Do you want to send an email with attachments from a list to specified person when the expiration date is equal to today?

 

After the trigger, initialize an array variable first.

 

Instead of using a Condition to filter expiration date equals to today, I suggest use Filter query of action Get items. The function used in my scenario is:

DueDate eq '@{utcNow('yyyy-MM-dd')}'

 

Then Get attachments and Get attachment content actions. Apply to each and Apply to each2 will be automatically added for each step.

 

Within Apply to each2, under Get attachment content, add Append to array variable with the following value:

 

{

  "Name": ⁠DisplayName,

  "ContentBytes": ⁠ body('Get_attachment_content')['$content']



}

 

 

Under Apply to each2, send an email to specified person. And select Attach variable for the Attachments field.

Note: you need to click the icon to switch to input entire array.

 

Then all the attachments will be sent out to the specified person at a time.

1.PNG2.PNG3.PNG

 

More details about Odata filter query for your reference:

https://flow.microsoft.com/en-us/blog/advanced-flow-of-the-week-filtering-with-odata/

 

Best regards,

Mabel

 

Community Support Team _ Mabel Mao
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

3 REPLIES 3
yashag2255
Dual Super User II
Dual Super User II

Hi @chanafee 

 

So in your Apply to each loop, before the condition part, add an action -> Get attachments and use the ID from the dynamic selector. After this, add another apply to each action and this time put value from get attachments. Now in this apply to each 2 loop, add an action of condition and on the left side put formatdatetime(spccolumn, dd-mm-yyyy) operator is equal to and then on the right side put formatdatetime(utcnow(),'dd-mm-yyyy'). after this in the yes branch add an action send an email. 

 

This will check for all the attachments in all the items. 

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

v-yamao-msft
Community Support
Community Support

Hi @chanafee ,

 

Do you want to send an email with attachments from a list to specified person when the expiration date is equal to today?

 

After the trigger, initialize an array variable first.

 

Instead of using a Condition to filter expiration date equals to today, I suggest use Filter query of action Get items. The function used in my scenario is:

DueDate eq '@{utcNow('yyyy-MM-dd')}'

 

Then Get attachments and Get attachment content actions. Apply to each and Apply to each2 will be automatically added for each step.

 

Within Apply to each2, under Get attachment content, add Append to array variable with the following value:

 

{

  "Name": ⁠DisplayName,

  "ContentBytes": ⁠ body('Get_attachment_content')['$content']



}

 

 

Under Apply to each2, send an email to specified person. And select Attach variable for the Attachments field.

Note: you need to click the icon to switch to input entire array.

 

Then all the attachments will be sent out to the specified person at a time.

1.PNG2.PNG3.PNG

 

More details about Odata filter query for your reference:

https://flow.microsoft.com/en-us/blog/advanced-flow-of-the-week-filtering-with-odata/

 

Best regards,

Mabel

 

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

Thank you!!!!!

Helpful resources

Announcements
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.

New Process Advisor Capabilities carousel.png

Read the blog for the latest news

Read the latest about new experiences and capabilities in the Power Automate product blog.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (3,049)