How to extract URL from a hyperlink in an email so I can assign URL into a variable

Hi,

Would anyone know how to go about extracting the URL from a hyperlink in an email in UiPath like which command/activity so I can assign it into a variable then. An example is shown in the screenshot where the URL is in the “Click Here” hyperlink. Any help would be greatly appreciated please.

image

Hi @ciaramkm,

I’ll suggest you to use Get Attribute with “href”.
image

2 Likes

yeah @samir was right
Use get attribute with “href”

@ciaramkm

Welcome to our UiPath community.

Please check below thread for your reference.

I won’t be able to use the get attribute activity as I won’t be opening the email in view so instead I’m using expressions to take some strings but the hyperlink is where I’m caught. For example let’s say I wanted to get a name from the line First Name: Robot so I’d be using body.ToString.Substring(body.ToString.IndexOf(“Name”)+"First Name: ".Length).Split(Environment.NewLine.ToCharArray)(0) and that returns the name Robot which works fine for me

So I need an expression to extract the URL from the Click here hyperlink if any of you would have an idea?

Actually I attempted the following = body.ToString.Substring(body.ToString.IndexOf(“Click here”)+“Click here”.Length).Split(Environment.NewLine.ToCharArray)(0)

but it returned the value with the two arrows at both sides of the hyperlink so next challenge is get that hyperlink without the two arrows in that string

hyperlink contains text like “click here <file:///C:/Users/SRajR/Documents/TestMacro.xlsm.xlsx>” while we read through the get outlook mail activity. So the “<” and “>” can be the start and end point of the text.
Please check the attached workflow.Sequence.xaml (7.1 KB)

@ciaramkm
Then simply use,

System.Text.RegularExpressions.Regex.Replace(strVar, "<|>", "")

I used the following then Hyperlink.Substring(2, Hyperlink.Length() - 4)
and now works like a charm. Thanks everyone for your help.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.