cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
soylaunica Helper I
Helper I

Parsing Email Body with a URL that Changes

I'm currently working on a multi-level approval workflow where we are parsing out an email and taking the information to pass-through to a quote approval request formatted email to get approved. Below you will find the structure of the email. My biggest hiccup currently is related to the link that follows "Please click to open quote attachment". A requester can add any number of file types for the customer to review as supporting documentation for the quote. Because the last part of the url will change based on the file name, I find myself at a loss as to the best way to parse it out without throwing an error. Additionally, if the user does not attached supporting documents, that verbiage and url are not there in the email at all. This is the current expression I have, but I know that it will eventually throw an error. the replace '-' with '' is to accommodate the possibility of a signature line that's embedded into our email when we send. Which also may or may not happen. Any recommendations? I have put "x" for confidentiality but the character count is accurate.

 

Email output to be parsed:

Quote#: 1234

Quote Amt: 10.00

BU#: 1234567

Customer Email: xxxxx@xxx.com

Originator Email: xxxxxx@xx.xxxxxx.com

 

 

Please click to open quote attachment

xxxxs://xxxxxxxxxx.xx.xxxxxxxx.com/QuoteDocs/filename.filetype

 

Expression to parse out URL

if(contains(substring(body('Html_to_text'),indexOf(body('Html_to_text'),'https'),add(sub(add(lastIndexOf(body('Html_to_text'),'QuoteDocs'),10),indexOf(body('Html_to_text'),'https')),50)),'-'),trim(replace(substring(body('Html_to_text'),indexOf(body('Html_to_text'),'https'),add(sub(add(lastIndexOf(body('Html_to_text'),'QuoteDocs'),10),indexOf(body('Html_to_text'),'https')),50)),'-','')),trim(substring(body('Html_to_text'),indexOf(body('Html_to_text'),'https'),add(sub(add(lastIndexOf(body('Html_to_text'),'QuoteDocs'),10),indexOf(body('Html_to_text'),'https')),50))))

1 ACCEPTED SOLUTION

Accepted Solutions
soylaunica Helper I
Helper I

Re: Parsing Email Body with a URL that Changes

Hi @RezaDorrani,

 

This almost worked, but was still giving me an isuse if there was a signature in there. So I ran with what you did and ended up doing the following with 3 compose actions, please feel free to let me know if there is a different, better or best practice way of achieving the same thing:

 

Final Draft.png

View solution in original post

3 REPLIES 3
Highlighted
Dual Super User
Dual Super User

Re: Parsing Email Body with a URL that Changes

Hi @soylaunica 

 

since the url is always the last line in your text body

 

first create a Compose action 

rename it to NewLine

and use following expression

decodeUriComponent('%0A')

Untitled.png

then use expression below to get the url

 

last(split(body('Html_to_text'),outputs('NewLine')))
 
this will give you the url
 

Regards,

Reza Dorrani

 

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

 

soylaunica Helper I
Helper I

Re: Parsing Email Body with a URL that Changes

Hi @RezaDorrani,

 

This almost worked, but was still giving me an isuse if there was a signature in there. So I ran with what you did and ended up doing the following with 3 compose actions, please feel free to let me know if there is a different, better or best practice way of achieving the same thing:

 

Final Draft.png

View solution in original post

Dual Super User
Dual Super User

Re: Parsing Email Body with a URL that Changes

@soylaunica 

 

if it works then code is fine 🙂

 

If it is not working then share the structure (sample data)

 

Regards,

Reza Dorrani

 

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

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

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

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (8,197)