How to get a dynamic Links in Mail Body content?

If the Body content of the mail contains “”. So , I need to click that link given in the body and navigate the further process.

Can any one help to achieve this scenario?

Regrads and Thanks
Kiruthika A

Hi @keerthi_arumugam

Is there any specific keyword that can occur before or after the Dynamic Links.


yes… I think so

@keerthi_arumugam ,

We could use an Open Browser Activity to open the web url or even Navigate URL Activity could be used to Navigate to the URL if a Browser is already opened.

But the Problem we do think is the extraction of the Link from the Mail Body. For that we would require you to provide samples of data present in email body in text format, so we could Provide you with a Regex Pattern to extract the data required.

If so, you can get the mail body by using


and then using Regex Pattern you can achieve the links


System.Text.RegularExpressions.Regex.Match (str_Link, “(?<=Prefix)(.*)(?=Suffix)”).Value


yes i already get a Mail body by using regex but Link are in the word format so could you please provide solution for link extraction?

This is a how the email body will displayed…so far i need to click the download link only prefix by the Capital Account Statements and start navigation

1 Like

@keerthi_arumugam , Could you Let us know How are you Reading the Emails ?

Are you using UI Automation or using Mail Activities such as Get Outlook Mail Messages ?

Mail Activities…

@keerthi_arumugam , In that case, Could You provide us with the Data from the mailMessage variable ?

mailMessage.Body should provide you with the contents of the mail Body. If this doesn’t contain the data, then using mailMessage.Headers("HTMLBody") should provide us with the full content of the Mail.

We can then use Regex to extract the links from this text data.

1 Like

in addition to @supermanPunch

when receiving the HTML Body alternate: YourMailVar.BodyAsHtml()
we can react on the a elements an on its href attribute w.g. with regex

refering to group:

simplified to only href anchoring:

In case we want to avoid to grab every present link and scope to the Download text we can do:


Can you please give me as a xmal file please…

will not help you much, as we don’t have the download links contents

But in general it is about:

  • get mail
  • iterate over the mails with a for each
  • retrieve within an assign the email body: strBody = yourLoopedMailVar.BodyAsHtml()
  • use regex eg
    arrLinks = System.Text.Regularexpressions.Matches(strBody, YourPatternVar).Cast(of Match).Select(Function (m) m.Groups(1).Value).toArray

YourPatternVar = (?<=href=")(.*?)(?=")(?:.*?)(?=Download)

More about regex you can find here:
[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum

1 Like

Yes, will started trying already…so if any queries, let you know…

Hello @keerthi_arumugam,

One question - Do we get the dynamic links in the email body starting with “https*” ?

If Yes then

We can use the “Split” operation on “ExtractedEmailBody” with the word “https://” and do the rest of the string manipulation functions.

Please refer to the attached file for a basic solution to extract dynamic links from the email body.
Outlook_ExtractingDynamicLinks.xaml (11.5 KB)

1 Like

No,But i have the specific word like “Capital Account Statement” prefix the Download(link) in boday content

1 Like

Hello @keerthi_arumugam,

I suggest you to use the workflow file attached to the above reply to test emails at your end. I have designed and tested it in such a way that it will extract any dynamic link in the email body.

Assumptions -

  1. Only 1 link will be there in the email body
  2. Link should be starting with https://
    Eg. -

PFA - Sample Email body I used for testing the above workflow file. It is capable of extracting links irrespective of email body content as far assumptions mentioned above are met.
Note - If it does not meet your requirement then do share a sample email body or similar content so that it will clear my doubts.

1 Like

Hi,I need to get a link by the specific word.

For example:
if a mail body content is displaying the “Download” or some other word is displayed and need to get the inner link of the word.

body HTML.txt (25.1 KB)
I need to Extract the Link by Prefix with Capital Account Statement and also download link