How to extract particular link from Mail Body

I have a mail body like this

I need to open the second link in chrome, But the problem is both links look almost the same can anyone help me with this

Hi @Ishan_Shelke

Can you read email with html body and print the email body in write line & share that text here, so that we can help you on this?

@Ishan_Shelke
use regex fro particular word to particular word.
(?<=Network:(\s)).(?=Regards)

Hi,

Read the mail body into the string. Then use regex to find link from the body. You will get list containing links. You just need to iterate on that list.

Mark it as solution if it resolves your issue.

Thanks

1 Like

Here it is

Dear Purchase Recon,
Please click on the below link to download your accounting report:
Generation Mode:Test Mode
https://api-v2.happay.in/transaction/v1/get-file-from-temporary-link/

If the above link is not accessible from our network:
https://api-v2.happay.in/transaction/v1/get-file-from-link/s3-ap-southeast-1.amazonaws.com

Regards,
Team Happay

(NEED TO EXTRACT THE SECOND LINK)

Hi @Ishan_Shelke

Is this below line is constant in the email body?
If the above link is not accessible from our network:

If yes then you can use below code to extract the 2nd URL from email body,
secondLink_URL(String DataType) = System.Text.RegularExpressions.Regex.Match( mailBody,"If the above link is not accessible from our network:\n(.*)", System.Text.RegularExpressions.RegexOptions.Multiline).Groups(1).Value.Trim

Find below screenshot for reference,

Hi @Ishan_Shelke ,

Could you maybe try the below Regex Expression :

https:\/\/.*

image

Expression :

System.Text.RegularExpressions.Regex.Matches(strInput1,"https:\/\/.*")(1).Value

Visuals :
image

Let us know if the method doesn’t work for your case.

2 Likes

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