cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
JMFralick
Level: Powered On

Count attachments on email excluding file type

 

 

Is there a way to have the flow condition count the attachments that are NOT of a file type. 

 

Example. 

Shared inbox receives an email with 2 attachments. 

 

example.pdf

0000001.jpg

 

Our company uses an email signature (required by all) that has an image. Exchange/Flow recognizes the image as a jpg attachment. I want the condition to count the number of attachments that are NOT .jpg files. 

 

So in the example above, I'd like to have the condition ignore the jpg and only count 1 as the number of attachments. 

 

 

 

 

So the flow would go. 

Trigger: Email arrives in shared inbox

Get email

Condition: If # of attachments = 1 (excluding .jpg)

yes: save 1 file to sharepoint folder excluding jpg > create link to specific file

No: save files to sharepoint folder excluding jpg > Create link to folder with files

 

I got everything else to work well, but the count.

 

I don't really have any screen shots - couldn't get the condition to ever work right.

 

Any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Count attachments on email excluding file type

I think you may need to move your condition = 1 outside of the first  Apply to each.  

 

The first Apply to each would just give you the total number so we know if there is more than one addachment that is not a jpeg.  The second apply to each would loop through again and if it is not a jpeg create the file or folder.   I did not create all the details for creating the file or folder but if that is also not working please let me know and I will keep working it.

AttachmentsFileorFolder.jpg

 

View solution in original post

7 REPLIES 7

Re: Count attachments on email excluding file type

Here is what I came up with that I think will work for you.

 

The only thing that you can't see in the image is the Expression for the first set variable. Here it is...

add(variables('TempNumber'),1)

CountAttachments.jpg

 

We have to create two variables because we can not use the "Add" expression to update itself. The TempNumber variable allows us to update the temp and inturn update the Attachments variable.

 

 

JMFralick
Level: Powered On

Re: Count attachments on email excluding file type

Thanks, I'll give this a try. 

JMFralick
Level: Powered On

Re: Count attachments on email excluding file type

I can get this to run with 2 attachments and it behaves as expected.  

sample.xlsx

image.jpg

 

However with more than 2

sample.pdf

flyer.pdf

image.jpg

 

It only seems to update the attachment variable by 1 instead of by 2. My condition after looks at the attachment value. If it is 1 it creates a link directly to that item. If it is 2+ it should create a link to the folder with items. 

 

Do you see any error in my setup here? Not sure if my second condition is wrong or if the update temp is only running for the 1st attachment it finds that is not jpg.

 

2019-01-25_0900.png2019-01-25_0901.png

Re: Count attachments on email excluding file type

I think you may need to move your condition = 1 outside of the first  Apply to each.  

 

The first Apply to each would just give you the total number so we know if there is more than one addachment that is not a jpeg.  The second apply to each would loop through again and if it is not a jpeg create the file or folder.   I did not create all the details for creating the file or folder but if that is also not working please let me know and I will keep working it.

AttachmentsFileorFolder.jpg

 

View solution in original post

Re: Count attachments on email excluding file type

I also think outside of the last Apply to each you will need to "Get files" to get the ID of the Folder you created. Once you have the ID of the folder you should be able to create your sharing link based on the ID.

 

I have to step away to get some of my task finished for the day but if you are still stuck I will try to finish the process on my end this weekend.

Re: Count attachments on email excluding file type

@JMFralickdid this help solve your issue?

JMFralick
Level: Powered On

Re: Count attachments on email excluding file type

Thanks for the reminder! I got locked up in another task with hair on it and forgot to get back in here. Yes, you were very helpful. I'll mark this as solved!

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,428)