Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

Get email - control attachment name repeats

(0) ShareShare
ReportReport
Posted on by 10

Hello,

 

I am new to Power automate and am trying to get rid of manual email moving.

I have a good idea but do not seem to get it to work.

I hope one of you experts can help me with this.

 

I am building a flow that collects email from a shared mailfolder (=cloudflow).

Once the email is collected a few checks are applied.

 

Stage one is always succesfull.

Emails from certain senders are selected and undergo a rework to flatten the email.

 

However when criteria 1 is not met I run into trouble.

The idea is that if there is a different sender, then the flow should check the email attachments.

If one of the attachments is an xml file then it should be moved to a folder.

If no XML file is found a next stage is applied which checks for PDF files and so on.

 

However, each email usually contains multiple attachments. and there is where it goes wrong.

When I use the Apply to each "Value" or "Current item" the flow blocks.

 
Value error
InvalidTemplate. Unable to process template language expressions for action 'Condition_-_XML_selector' at line '1' and column '24260': 'The template language function 'endsWith' expects its first parameter to be of type string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#endswith for usage details.'.
 
Current item error 
ExpressionEvaluationFailed. The execution of template action 'Apply_to_each_-_XML_selector' failed: the result of the evaluation of 'foreach' expression '@items('Apply_to_each_-_TXT_forward_selection')' is of type 'Object'. The result must be a valid array.

 

If I use the Apply to  Each "Attachments" the flow processes 1 email multiple times (1 time for each attachment found)

And thus applies the subsequent action for as well yes as no and the email ends up in the wrong place.

 

- I need the flow to check if any of the attachments meets the condition. 

- Then apply the subsequent steps to the email (being if yes, move the email ; if no, check for the next condition)

 

 

Below an example of the multiplication.

This is the result of 1 email being processed.

The email contained multiple attachments

Dirk_Belgium_4-1634653821516.png

 

 

Here the build of the flow

Dirk_Belgium_1-1634653528481.png

Dirk_Belgium_2-1634653665957.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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1