Read embedded hyperlinks from all emails in gmail

Hello All,

I need to fetch the hyperlinks embedded in some text in the email body from gmail. The text looks like this:

Please review and initiate the PO issuance process for:
Project Name: XXXXXXX
BOB: XXXXXXX
Sub-activity: Tracking (ATUs, advertising, etc.; excludes Chart Audits)

Superform: SUPERFORM 2017 GIO FPM ATU

In this, the last line “Superform…” has a hyperlink embedded to download a file. I need to fetch that hyperlink and open it in a browser to start the download. Please suggest a way to do this

Check if it helps,

Thanks,
Rammohan B.

My bad. Just the mail.body.toString works. I used regex on top of it.

Thanks

2 Likes

I do not have the url explicitly listed in the email body. However, I found a workaround and got it working. Thanks though

If you have followed a different approach then the one above, i would request you to please post your solution here in the thread. It helps someone who face may face a similar challenge in the future.

Thanks,
Rammohan B.

I just fetched the plain text of the email which comes as HTML tree and then parsed it to find the URL I need.