cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

Help Cleaning Up Outlook Attachment To Remove Special Characters

I get an xml report emailed to me daily and my flow saves the attachment to a folder in Teams which Excel then uses as a data source. Sometimes the XML contains invalid characters (Hexadecimal 0x01 is an example) and it stops excel from accessing the data.

 

I've tried searching for a way to handle this in Excel but couldn't get a solution, so I figured there might be a way with Power Automate.

 

Is there a way this could be done where the XML file is cleaned up using Power Automate before it's saved to the Teams folder?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

This was fun, and taught me something new (I feel a blog post coming on!). It can be done and it is pretty easy.

 

Check out this image https://ibb.co/PcFvbq5 :

Power-Automate-Remove-Unprintable-Chars.png

 

The code for the "Badchars" array is:

["\u0001", "\u0002", "\u0003", "\u0004", "\u0005", "\u0006", "\u0007", "\u0008", "\u0011", "\u0012", "\u0016", "\u0017" ]

See how you get on.

 

Please...

If I answered your question Accept it as a solution ✔️ 

If I helped you out, please give me some Kudos 👍

Thanks 😙

View solution in original post

9 REPLIES 9
Highlighted
Regular Visitor

The characters I need to remove are covered by this regular expression: [\x00-\x08\x0B-\x0C\x0E-\x1F]

Highlighted

This sort of thing is tricky in PA as there is no regular expression support (which is a real pain and I wish it would be added). I was going to ask you to post a sample of the file, but that isn't going to help as the characters will likely be lost.

 

Can you put a sample file on the web somewhere we can download and examine? It does sound like a good challenge.

 

Highlighted

Here's a link to a snipped of the data that has these characters in it

 

Snippet of data 

Highlighted

This was fun, and taught me something new (I feel a blog post coming on!). It can be done and it is pretty easy.

 

Check out this image https://ibb.co/PcFvbq5 :

Power-Automate-Remove-Unprintable-Chars.png

 

The code for the "Badchars" array is:

["\u0001", "\u0002", "\u0003", "\u0004", "\u0005", "\u0006", "\u0007", "\u0008", "\u0011", "\u0012", "\u0016", "\u0017" ]

See how you get on.

 

Please...

If I answered your question Accept it as a solution ✔️ 

If I helped you out, please give me some Kudos 👍

Thanks 😙

View solution in original post

Highlighted

Sorry, the first image I posted isn't completely easy to follow, check out this one:

https://ibb.co/fYpQ2yx

Highlighted

Thanks, that looks really good!

 

Would it be easy to do this for an email attachment? I'd like to be able to clean up the attachment before it's saved to the folder location.

Highlighted

No reason that you couldn’t do it on an email attachment. You’re going to need a condition or two to make sure you’re not just doing it to any attachment. But sure, go for it.

Highlighted

Worked a treat with the email attachment 👌

Highlighted

Well done 👍 Pretty pleased with that solution!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (10,826)