Get a link from Button in Email Body

Hi,

Could you please help me, I want to get a link from a button in the email body and open it in the browser.

@aalaghbari Can you explain a bit more as to how the process is done manually? If Clicking on the button opens the Link in a Browser, then you can use Click Activity.

Hi, I use Get IMAP Mail Messages first then I used for each as per the below screenshot

@aalaghbari Ok. My Apologies i thought you were working on a UI Automation Scenario :sweat_smile:

So Nothing related to the Button appears in the Email Body ?

Inside the email body a button with a link I want to get that link and open it in the browser.

Please find below the email body

@aalaghbari Yes. What values do you get when you use for each to iterate eamils and extract email body? Were there any values in the Email Body? If so is there any values related to the Button or a HTML code?

I got only the text value.

@aalaghbari Ok. Can you try with this Expression :
item.Headers(“HTMLBody”).ToString

@aalaghbari - get the mail.body to a string variable and check if any hyperlink text available for ‘view the item’ in the body string. if you see any hyperlink? pls use the regex to get the hyperlink between text…

regex: for hyperlink between text
(?<=HYPERLINK ")(.*)(?="Click)

Ok, after this step how can I extract the link in the button?

@aalaghbari Can you Show us the Value what you got using that Expression, You’ll need to perform String Manipulation or Use Regex to get the Value from it.

@aalaghbari Can you send that as a txt file here and tell us which is the link that you need ?

This link

@aalaghbari Yes Can you please Send the txt file, so that i can test and provide the right regex expression

View the Item

Thelink.txt (399 Bytes)

@aalaghbari Can you check with this Expression :
System.Text.RegularExpressions.Regex.Matches(item.Headers(“HTMLBody”).ToString,“(?<=<a href=).*(?=style)”)(0).ToString.Trim

I got the following error ( Specified argument was out of the range of valid values.)

@aalaghbari I’m able to get the Output for the text provided using that Expression, I’m nt sure if it is because you have only provided only the part which you need, can you send the Whole Text so that I can check for that? Even you can try Checking using this link :