cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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

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

7 REPLIES 7
Super User II
Super User II

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

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

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

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

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

 

image.png

 

Hi,

I am facing a similar issue only that the URL is in between the email text, how can this be split? 

 

aanyoti1_0-1600236281181.png

 

Hi @aanyoti1 

Can you raise a new thread and clearly explain what your trying to achieve? i.e. the input and outputs you require

Thanks J

Helpful resources

Announcements
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (48,034)