cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
MrNigel
Level 8

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:

 

URL1.PNGOutlook 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
Super User
Super User

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

3 REPLIES 3
Super User
Super User

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

MrNigel
Level 8

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:

 

URL3.PNGAdded 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

Super User
Super User

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

Helpful resources

Announcements
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!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

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 (Last 30 Days)
Users online (5,150)