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

Extracting URL from email body text

Hello

I'm trying to set up a flow where when an email is flagged a new task is created in Planner. So far I've managed to set up the flow successfully whereby it pulls all of the email body text (converted from HTML to text) into the description of the task but I'd ideally like it to just be the URL from within the email. 

I've tried following this solution: https://powerusers.microsoft.com/t5/Building-Flows/Extract-URL-from-Email-body/m-p/695681#M94225 but something just isn't working for me. I only have 'Compose' action and not 'Compose - Trim Start' or 'Compose - Replace Chars':

LaurenAddison_1-1618850251685.png

This is my current flow:

LaurenAddison_2-1618850326387.png

Can anyone help me please!?

1 ACCEPTED SOLUTION

Accepted Solutions
Paulie78
Super User
Super User

Hi @LaurenAddison ,

 

Here are the screnshots and expressions:

2021-04-19_21-27-24.png

All of these should be after the Html to text action, expressions are:

startPos...
indexOf(outputs('Html_to_text')?['body'], 'https://docs.google.com')

endPos...
indexof(substring(outputs('Html_to_text')?['body'], outputs('startPos')), 'sharing')

URL...
substring(outputs('Html_to_text')?['body'], outputs('startPos'), add(outputs('endPos'),7))

All are compose actions. See how you get on.

View solution in original post

12 REPLIES 12
Paulie78
Super User
Super User

Would you be kind enough to post the raw outputs of the HTML to text action? Then we can see if we can make an expression to pull out the URL? If possible use the code window to post it.

2021-04-19_17-55-22.gif

Thanks for responding!

I think one of these are what you were looking for? The URL is a Google Docs link.

LaurenAddison_0-1618851914579.png

 

 

Paulie78
Super User
Super User

lol, that is a bit more than I was looking for, but that will do. 😂

Paulie78
Super User
Super User

Are you trying to grab:

https://docs.google.com/document/d/1Coy_qI5qUAFlMbh2CLWP73Bs9ecK5vlevhaGBhcITx4/edit?usp=sharing

Correct? 

As you are parsing a human written email, this is likely to wrong in future, but I can make you something that will pull that out of the email in this instance?

 

Yes, that's what I'm trying to extract and yes, please can you help me with this instance.

Paulie78
Super User
Super User

ok, try this:

  • Copy the code below to your clipboard.
  • Add a new action in your flow after your "HTML to text" action"
  • Click on my clipboard.
  • Click paste.

A bit like this:

2021-04-19_06-56-02.gif

Except your one is called getURL. Because a couple of the concepts are a little complicated I have separated the actions into different steps, so you can better understand what is going on.

 

After you paste, you will have a scope which will contain the steps that give you the URL, but these are intended to be chained off the action, HTML to text, so must go after it.

{"id":"2b75eb54-de4b-4cb5-8ab0-96c4-e6bf1982","brandColor":"#8C3900","connectionReferences":{"shared_conversionservice":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_conversionservice/connections/shared-conversionser-8c945934-2489-4e84-98ab-725c-31760fc1"}}},"connectorDisplayName":"Control","icon":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=","isTrigger":false,"operationName":"getURL","operationDefinition":{"type":"Scope","actions":{"startPos":{"type":"Compose","inputs":"@indexOf(outputs('Html_to_text')?['body'], 'https://docs.google.com')","runAfter":{}},"endPos":{"type":"Compose","inputs":"@indexof(substring(outputs('Html_to_text')?['body'], outputs('startPos')), 'sharing')","runAfter":{"startPos":["Succeeded"]}},"URL":{"type":"Compose","inputs":"@substring(outputs('Html_to_text')?['body'], outputs('startPos'), add(outputs('endPos'),7))","runAfter":{"endPos":["Succeeded"]}}},"runAfter":{"Html_to_text":["Succeeded"]}}}

See how you get on.

LaurenAddison
Helper I
Helper I

Thanks for this! I copied the code and then went to Power Automate, but its just showing me this: 

LaurenAddison_0-1618853202087.png

 

Paulie78
Super User
Super User

Are you sure you copied the entire code? If you miss one character it will not appear, if it does not work for you I will screenshot it.

LaurenAddison
Helper I
Helper I

This is what I'm doing and still no luck:

LaurenAddison_0-1618853499726.png

 

Paulie78
Super User
Super User

Not sure what is going on there, another user just tested pasting it for me and it worked for them. Will do you some screenshots, but can't do it right now. Will post screenshots in about an hour.

Paulie78
Super User
Super User

Hi @LaurenAddison ,

 

Here are the screnshots and expressions:

2021-04-19_21-27-24.png

All of these should be after the Html to text action, expressions are:

startPos...
indexOf(outputs('Html_to_text')?['body'], 'https://docs.google.com')

endPos...
indexof(substring(outputs('Html_to_text')?['body'], outputs('startPos')), 'sharing')

URL...
substring(outputs('Html_to_text')?['body'], outputs('startPos'), add(outputs('endPos'),7))

All are compose actions. See how you get on.

LaurenAddison
Helper I
Helper I

That works! Thank you so much for your help.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (2,784)