cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate V
Advocate V

Using @split to extract URL from email body text

We have a solution that sends emails containing a URL at the start of the body text (with further text after the URL which we want to discard) and want to upload this to a SPO list URL column.  This is a standard "When new email arrives" --> "HTML to text"-->"Compose @split" flow.  This is the email body in Outlook:

 

Outlook email body textOutlook email body text

 

The output from the HTML to text action looks OK except that the space after the URL is bring translated to a new line:

 

https://techcommunity.microsoft.com/t5/Microsoft-Forms-Blog/What-s-New-in-Microsoft-Forms-Oct-Nov-20...
This is text after the URL

 

We are using @split to extract the URL only as this is the first 'column' but in the split function I have tried ' ', '%20', '\n' for the separator but it just passes all the text through:

 

This is the function in the Compose action, I have tried double quoting it as per other articles but it makes no difference:

 

split(body('Html_to_text_-_email_body'),'\n')
 
All I want is the URL https://techcommunity.microsoft.com/t5/Microsoft-Forms-Blog/What-s-New-in-Microsoft-Forms-Oct-Nov-20...so I can use it in a Create item action to fill at SPO list URL column.
 
I guess I am missing quotes/brackets somewhere but cannot figure out which/where.
 
TIA
 
Nigel

 

 

 
 
 
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User II
Super User II

Re: Using @split to extract URL from email body text

Hey @MrNigel 

I've tested this as per the Flow I'd sent across, it does work 🙂

Can you add a screen shot showing the outputs from each of the actions? and can you share the configuration of your 'Create item - SPO List' action please?

%0A is the encoded representation of '\n'... you can't use ' ' or '\n' to split a string... but you can split a string using the encoded version which is why I'd converted to a URI.

Example:

a.png

 Cheers J

View solution in original post

5 REPLIES 5
Highlighted
Super User II
Super User II

Re: Using @split to extract URL from email body text

Hey @MrNigel 

I think this does what you need... I played with this for quite a while and may have missed what you're trying to do!

The email...

1.PNGThe final extracted output from the HTML email body: https://techcommunity.microsoft.com/t5/Microsoft-Forms-Blog/What-s-New-in-Microsoft-Forms-Oct-Nov-20

1.PNG

The Flow:

1.PNG

The expressions:

'Compose - URI Encode' : uriComponent(body('Html_to_text'))

'Compose - Split on Encoded Line Break' : split(outputs('Compose_2'),'%0A')

'Compose - Decode First Item in Array' : decodeUriComponent(first(outputs('Compose')))

HTH

Jay

-------------------------------------------------------------------------

If I have answered your question, please mark your post as Solved.

If you like my response, please give it a Thumbs Up

Highlighted
Advocate V
Advocate V

Re: Using @split to extract URL from email body text

Hi Jay,

 

Updated my Flow with your mods, all green ticks but when I look at the SPO list then entire body text has been saved as a URL:

 

Added the expressions as a comments so visibleAdded the expressions as a comments so visible

 

What it has done is encode the entire body text as a single URL string (presumably the lat Compose action doing its stuff!  IMHO it is the split function 'separator' that is the issue.  To test it I used the letter 'm' and it duly broke up the string on every occurrence of 'm'.  I have tried various combinations of '%0A', '%0D', '\n', '\\n' but all pass through the body text unaltered.  It seems to be an issue when using a non-ASCII separator character - I even tried removing the single quotes around the %0A but that wouldn't let me save.

 

Has anyone successfully used @split with a non-ASCII separator?

 

Tks

 

Nigel

Highlighted
Super User II
Super User II

Re: Using @split to extract URL from email body text

Hey @MrNigel 

I've tested this as per the Flow I'd sent across, it does work 🙂

Can you add a screen shot showing the outputs from each of the actions? and can you share the configuration of your 'Create item - SPO List' action please?

%0A is the encoded representation of '\n'... you can't use ' ' or '\n' to split a string... but you can split a string using the encoded version which is why I'd converted to a URI.

Example:

a.png

 Cheers J

View solution in original post

Highlighted
Frequent Visitor

Re: Using @split to extract URL from email body text

Im trying to do the same, Extract a URL from an Email, that i receive daily, this Link is a ZIP file that i save to sharepoint.

 

Problem is , when @split to extract i get the whole email body and not just the url

Highlighted
Advocate V
Advocate V

Re: Using @split to extract URL from email body text

@master_NK This is how I did it, the key item is  the '%0A'

 

image.png

 

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

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!

Top Solution Authors
Top Kudoed Authors
Users online (9,138)