How do I read embedded links from an email body?

Hey All,

I’m reading the mail body by using “Get Outlook Mail Messages” activity and a “For Each” with assigned values to read from “Approval Type” to “Internal Transfer Subject”.

I have two embedded links in the mail body. How do I read those separately ?

Email Body :-

Dear ABC,

Approval Type - Internal Transfer Request
Purpose Of Transfer - Normal Transfer
Internal Transfer Number - ITRAP-000897525
Date of Submission - 24 June 2023
Originator - ABC
Internal Transfer Subject - From Commercial to Inspection Room

Click on the below link to proceed.

Click here - (search)
Click here - (watch )

Thanks and Regards,
XYZ.

@uio

Try reading the htmlbody which will contain the url as well

then use regex on it to get the data

mail.Headers("HTMLBody")

cheers

Can you please share a xaml file ?

@uio

Please check this on how to get htmlbody…from there you can use regex or split string to get the url

mailbody.xaml (7.3 KB)

cheers

Hello @Anil_G ,

Can you please add the method in the below attached project file ?

I don’t understand the method you’ve suggested.

Auto Approval.zip (3.0 KB)

Thanks,
Uio.

@uio Here’s a XAML you can try. When you have the HTML of the email, this uses the Regex Matches function and results into a Match Collection data type. You can loop through each of the collected URLs:

Text.RegularExpressions.Regex.Matches(strHTML, "(?<=<a href="")(.*?)(?="">)")

image

Auto Approval.zip (3,4 KB)

Hope this helps!

2 Likes

How do I assign two different variables for the URLs ?

@uio - You can assign like this and access the Items in the Match Collection:

strLink1 = coll_strURLs.Item(0).ToString
strLink2 = coll_strURLs.Item(1).ToString

Auto Approval.zip (3,4 KB)

Thanks!

@argin.lerit Thank you so much for your support.

1 Like

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