web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Count number of attach...
Power Automate
Unanswered

Count number of attachments in email

(1) ShareShare
ReportReport
Posted on by 19

In flow, I want to count the number of attachments in an email(outlook) and save in a excel or may be sharepoint. The table will only have the Date and Count the number of attachments fields. Can anyone help me how to make a Power automate flow??? I am new to Power automate???

@Pstork1 

@jinivthakkar 

Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    68,697 Most Valuable Professional on at
    • Use the When an EMail is received trigger and make sure to turn on include attachments.
    • Use the length() function on the attachments array to find out how many attachments there are.  You can put this in a Compose action.
    • Save the output of the compose and the date to the Excel Table where you want the data.
  • shantanu97 Profile Picture
    19 on at

    1. I tried your steps. But my flow is giving error. I don't know how to fix this error. If it is better if you give me attached screenshots. See Error-1
    2.In my flow I am not able to figure it out how I can calculate date field. I tried to create one more field for calculating Date Received. See Image-2
    3.How the compose values will be passed to excel table.

    Error

    Error.jpg

    Image-2

    shantanu97_0-1641196705002.png

     

     

    My Flow till Now:

    Screenshot 2022-01-03 184614.jpg

    Screenshot 2022-01-03 184733.jpg

  • Pstork1 Profile Picture
    68,697 Most Valuable Professional on at

    If all you want is to get the number of attachments and the date then you don't need any Apply to Each loops. Also in the compose you need to use the Expressions tab of the dynamic content dialog box to add the length() function.  The date and time the email arrived is already available from the trigger as Received Time.

  • shantanu97 Profile Picture
    19 on at

    Is the right formula to get the number of attachments. As it is not producing the correct result. When I put 2 attachments, the compose function is producing output as 3. Can you let me know what is the correct formula.

    length(triggerBody()?['Attachments'])

    shantanu97_1-1641719587172.png

    Regarding Received Time(Date & Time email), I need to use condition. Is there any way I get received time without the use of Condition???

    shantanu97_2-1641720517440.png

     

  • Pstork1 Profile Picture
    68,697 Most Valuable Professional on at

    The formula should be the right one.  Do you use any icons or anything in your signature?  Those will also be counted as attachments in the email. 

     

    The date and time that the email was received is included as dynamic content.  But if you want to filter based on the date and time then you will need either a condition or a filter array.

  • shantanu97 Profile Picture
    19 on at

    there are certain changes in the flow.
    1.The flow run at schedule time(9:00 am) in the morning. It should count the number of attachments in the last 24 hours. How I implement this logic?
    2. We need to count the number of attachments only certain files(.txt & .csv). Ignore all the other attachments.
    3.Which trigger I need to use??? I think I need to use "Export Email"??? Is it right??? If something else, please let me know.

  • Pstork1 Profile Picture
    68,697 Most Valuable Professional on at

    If you want to run it on a schedule, then the trigger needs to be a recurrence trigger.  Once the trigger fires you'll need to do a Get Emails.  This should be filtered so only emails with attachments received within the last 24 hours are retrieved.  Now that you have the emails you'll need to process each email by getting the attachments, counting the attachments with the extensions you want and incrementing a counter variable. 

  • AMICHAWL2 Profile Picture
    13 on at

    Thank you for being so helpful Pstork1 , how do incorporate the requirements of specific Extention of the file we need? What you wrote absolutely makes sense but I'm just starting my journey in doing this flow creation so do not know how to and what to do in steps while generating this result of counts. May I request you show me how to make it possible?

  • Pstork1 Profile Picture
    68,697 Most Valuable Professional on at

    After retrieving the files use filter array actions for each type to filter out all the files you don't want to count.  Then use Length() on the resulting array to get the number of files.

  • AMICHAWL2 Profile Picture
    13 on at

    Thank you so much for the prompt reply. I have pasted my screen to understand if I'm doing it correctly. But After doing this still, the count is not taking only PDFs. Tried using Content type, file attachment and attachments only but nothing seems to be working.

    AMICHAWL2_0-1674931105614.png

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard