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

Condition - Attachment Contains Causes Error

We have an alerting system that sends out messages, however the status of the alert (success/failure) is contained within a .txt attachment on the email. I am attempting to create a flow that will send me a notification based on the presence of the word "failed" in the text of the attachment.

 

I created the following flow based on the post here: Save attachment based on content

with the exact condition of: @contains(base64ToString(items('Apply_to_each')?['ContentBytes']), 'failed')

This results in the following error:

 

InvalidTemplate. Unable to process template language expressions for action 'Condition at line '1' and column '2394: 'The template language function baseo4ToString expects its parameter to be a string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#base64ToString for usage details.'.

 

Removing the conversion from base64tostring only causes the error to change to the following:

 

InvalidTemplate. Unable to process template language expressions for action 'Condition at line '1' and column '2394' : 'The template language function 'contains' expects its first argument 'collection' to be a dictionary (object), an array or a string. The provided value is of type 'Null'.'.

 

Based on this, I believe I am incorrectly requesting the attachment contents from Flow. The attachment I am testing with is a basic ASCII text file with no special characters or affectations created on a Windows PC using VSCode. I do not believe there is anything unique about the text file I am using to cause this behavior.

 

What error am I making in the way I am fetching the content of the email attachment?

1 REPLY 1
Community Support Team
Community Support Team

Re: Condition - Attachment Contains Causes Error

Hi @AaronDubin,

 

Could you please share a screenshot of your flow's configuration?

 

I have made a test on my side and don't have the issue that you mentioned. My flow's configuration as below:

  • Add a "When a new email arrives" trigger, Has Attachment field and Include Attachments field are both set to Yes.
  • Add a "Apply to each" action, input parameter set to Attachments dynamic content of the trigger.
  • Within "Apply to each", add a Condition, click "Edit in advanced mode", type the following formula:
@contains(base64ToString(items('Apply_to_each')?['ContentBytes']), 'failed')

     Within "If/yes" branch of Condition, add a "Send me an email notification" action.

 

Image reference:25.JPG

The flow works successfully as below:26.JPG

 

 

Please check if you have set Has Attachment field and Include Attachments field to Yes within the "When a new email arrives" trigger on your side.

 

Best regards,

Kris

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

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

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 Solution Authors
Top Kudoed Authors
Users online (5,086)