Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 23wFUuUEn+5sr5W9v9TT9Y
Power Automate - General Discussion
Unanswered

Count number of attachments in email

Like (1) ShareShare
ReportReport
Posted on 3 Jan 2022 01:02:37 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 

  • Suggested answer
    NJ-07081420-0 Profile Picture
    2 on 07 Aug 2024 at 14:23:49
    Count number of attachments in email
    You can use instead of filter : select , it worked for me 
    and then in compose : 
  • Pstork1 Profile Picture
    65,369 Most Valuable Professional on 29 Jan 2023 at 01:12:05
    Re: Count number of attachments in email

    YOu don't need a loop.  Just do the filter array and then length of the result

    image.png

    Pstork1_0-1674954702983.png

     

  • AMICHAWL2 Profile Picture
    13 on 28 Jan 2023 at 18:40:10
    Re: Count number of attachments in email

    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

     

  • Pstork1 Profile Picture
    65,369 Most Valuable Professional on 28 Jan 2023 at 17:57:57
    Re: Count number of attachments in email

    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 28 Jan 2023 at 16:21:02
    Re: Count number of attachments in email

    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
    65,369 Most Valuable Professional on 22 Jan 2022 at 14:06:16
    Re: Count number of attachments in email

    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. 

  • shantanu97 Profile Picture
    19 on 22 Jan 2022 at 11:08:46
    Re: Count number of attachments in email

    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
    65,369 Most Valuable Professional on 09 Jan 2022 at 13:36:04
    Re: Count number of attachments in email

    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 09 Jan 2022 at 09:29:42
    Re: Count number of attachments in email

    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
    65,369 Most Valuable Professional on 03 Jan 2022 at 13:33:13
    Re: Count number of attachments in email

    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.

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

Thomas Rice – Community Spotlight

We are honored to recognize Thomas Rice as our March 2025 Community…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,508 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,369 Most Valuable Professional

Leaderboard
Loading started