How to access url in the email notifications

Hi Experts, need help on this foll. business scenario
For e.g., my business reqmt. goes something like this →

  1. Create an employee in the application by entering all the details like firstname, lastname, DOB, DOJ, Benefit plans, etc.
  2. Then finally click on Create
  3. Then an email is triggered to the HR [the person involved in recruitment]
  4. The email contains an url
  5. HR [i.e., the person who receives it] has to click on the link → it redirects to the application
  6. HR verifies the employee details entered in step#1
  7. And finally HR can approve or reject
  8. The process gets completed when HR approves or rejects it

Now, Im able to automate steps#1 and #2 using Katalon, and unable to proceed from step#3
My question is → how do I access the url/link from the email that is triggered, using Katalon ?
Pls. note → email application can be gmail / outlook

Kindly let me know, many thanks

1 Like

Connect to the relevant email account (Gmail or Outlook), fetch the latest message, extract the required link, and then launch it for subsequent UI automation.

Use Katalon’s Built-In and Custom Keywords for Email Access

  • Gmail: You can use Katalon’s custom keywords along with JavaMail or Gmail API to connect and read the most recent email.
  • Outlook: Use JavaMail or Outlook-specific libraries to fetch messages from your inbox.
  • For Gmail (example JavaMail code):

groovy

import javax.mail.*
import javax.mail.internet.*
import java.util.Properties

Properties props = new Properties()
props.put("mail.store.protocol", "imaps")
Session session = Session.getDefaultInstance(props, null)
Store store = session.getStore("imaps")
store.connect("imap.gmail.com", "<email>", "<password>")
Folder inbox = store.getFolder("INBOX")
inbox.open(Folder.READ_ONLY)
Message message = inbox.getMessage(inbox.getMessageCount())
String emailContent = message.getContent().toString()
// Extract link using regex:
def matcher = emailContent =~ /(https?:\/\/[^\s]+)/
def url = matcher ? matcher[0][1] : ''
store.close()

This will retrieve the latest email and extract the first link found.

2. Open the Link in Katalon Studio Automation

  • Use the extracted URL and launch it with:

groovy

WebUI.openBrowser('')
WebUI.navigateToUrl(url)
  • Continue automation as needed (approve/reject employee).

3. Outlook/Exchange Integration

  • Use JavaMail for IMAP/POP3 access, or EWS/Graph API for advanced Outlook scenarios.

Notes

  • Store your email credentials securely. Avoid hardcoding sensitive data in scripts.
  • Ensure the script waits until the email arrives (may need a delay or polling logic).
2 Likes

Thanks DInesh

1 Like

You should try GMail API.

Ask AI, such as Copilot:

Please provide a sample Groovy script runnable in Katalon Studio that reads the body of an email using the GMail API.

Then you would be able to start learning the GMail API in Katalon Studio.

1 Like

If the business case involves Gmail, enabling API access and creating a service account can make it easier to programmatically read messages. Outlook has a similar option via Microsoft Graph API. Both methods ensure the link can be accessed consistently during automation.