I’ll provide a high-level overview of the process.
Nowadays, both Microsoft and Google have tightened their security policies and no longer support the traditional email access methods that were commonly used for test automation. Instead, email access must be performed through modern authentication mechanisms, such as Microsoft Graph API.
Since I have implemented this for Outlook, I can share the approach I followed:
1. Azure App Registration and Permissions
You need to register an application in Azure and generate the required credentials, such as the Client ID, Client Secret, and Tenant ID. These credentials are used to obtain an access token. During app registration, you must also grant the necessary Microsoft Graph API permissions (such as Mail.Read and Mail.Send) through the Azure Portal.
2. Access Token and Automation Development
Once the access token generation is in place, the next step is the coding implementation, which I demonstrated in the video. With the appropriate APIs and automation scripts, you can perform various mailbox operations, including:
- Fetching OTPs or access codes from emails
- Reading email content
- Deleting emails from Outlook
- Sending emails and automation reports
- Managing mailbox data programmatically
Due to my company’s security policies, I’m unable to share the source code directly. However, I have created additional use cases around these functionalities, and you may find them useful as references.
Also, I highly recommend leveraging StudioAssist or any AI-powered coding assistant. These tools can significantly speed up script development and help generate much of the required automation code.