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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Unable to Use 'CONTAIN...
Power Automate
Unanswered

Unable to Use 'CONTAINS' on CSV Email Attachment

(0) ShareShare
ReportReport
Posted on by 6

Good morning!

 

I am a very new Power Automate user attempting to do something (seemingly) simple:

Notify a user via Teams when an inbound email attachment (.csv) contains a specific string.

 

The general function of the Flow is working as-intended except for the condition that the whole thing depends on. I am able to use Get Attachment (V2) to get the appropriate attachment content via Content Bytes, and I can successfully Create File via SFTP or SharePoint. I can not, however, use the CONTAINS operator in a condition to read the contents of the CSV. Looking at the relevant output from a step shows me data that looks like this:

"contentBytes":"VQBzAGUAcgAgAEkAZAAsAFMAdABhAHQAdQBzACwAUgBlAGMAbwByAGQAIABTAHkAbgBjACAAVAB5AHAAZQAsAE8AcgBpAGcAaQBuAGEAbAAgAFMAeQBuAGMAIABEAGEAdABlACwATwByAGkAZwBpAG4AYQBsACAAUgBlAHEAdQBlAHMAdAAgAEkARAAsAE0AZQBzAHMAYQBnAGUADQAKADEAMAAwADEANgAsAFUAcABkAGEAdABlAGQALAAsACwALAANAAoAMQAwADAAMAAxACwAVQBwAGQAYQB0AGUAZAAsACwALAAsAA0ACgAxADAAMwAzADYALABVAHAAZABhAHQAZQBkACwALAAsACwADQAKADEAMAAyADYANQAsAFUAcABkAGEAdABlAGQALAAsACwALAANAAoAMQAwADIANwA5ACwAVQBwAGQAYQB0AGUAZAAsACwALAAsAA0ACgAxADAAMwA3ADQALABVAHAAZABhAHQAZQBkACwALAAsACwADQAKADEAMAA0ADUA

 

In case it needs to be stated, this is not what the actual content of the file looks like in CSV format. I was expecting my data to look something like this:

Fourhundred57_0-1622570831812.png

 

This leads me to believe there is some sort of conversion or transformation that needs to occur before I can read the data in a condition. If anyone is familiar with whatever format the contentBytes data seems to be in and how I can access my 'real' CSV data in a condition, I would be forever grateful.

Thank you!

Categories:
  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @Fourhundred57 

     

    You're correct.  Base64ToString is the expression that you need to give a try.  Load a file up from OneDrive and it is plain text, but SharePoint actions are Base64.

     

    I've also done an article on parsing CSV's which you might find interesting, and demonstrate the Base64ToString action here too https://www.damobird365.com/how-to-parse-a-csv-to-json-array-flow

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

  • Fourhundred57 Profile Picture
    6 on at

    Thanks, @DamoBird365!

    I think I'm getting closer, but now it appears I've gone from Base64 to UTF-16.

    Here's the original Base64 output I'm getting from my Get Attachment (V2) Content Bytes:

    Fourhundred57_0-1622638180518.png

    —and here is the output I'm looking at after using this expression:
    replace(base64tostring(outputs('Get_Attachment_(V2)')?['body/contentBytes']),'"','')

    Fourhundred57_1-1622638192087.png

    I am certain this is due to some failure in the expression, but I'm really just cobbling together things I don't understand at this point.

    As a way around all this, I tried to encode the word 'Failed' into Base64 and simply run a CONTAINS on that, but it seems that Base64 encoding isn't as simple as I'd hoped.

    —Arthur

     

    P.S.
    Your intro video on YouTube scared me into thinking Teams had AGAIN hidden an inbound call toast behind all of my other windows. 😋

  • rangernf Profile Picture
    2 on at

    Hi @Fourhundred57 ,

     

    I am having this same problem. Did you ever find out how to convert UTF-16 to a text string?

     

    Thanks

    Nic

  • Fourhundred57 Profile Picture
    6 on at

    Hey @rangernf—

    Sorta. I just needed it to work, so rather than digging too deep, I realized I had all of the characters I needed in that ugly output; they were just absolutely covered in a bunch of u0000s. I just ran a replace and replaced all those values with nothing, and it got me where I needed to be:

    @{replace(outputs('EMAIL')?['ATTACHMENT'],'\u0000','')}

     Best of luck!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 355

#2
11manish Profile Picture

11manish 336 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 308

Last 30 days Overall leaderboard