What you are wanting to achieve in verifying an email in Outlook is considered an anti-pattern in Selenium.
A lot of people think you can and should automate everything, when there are plenty of situations where automation doesn't make sense.
Take a look at the Selenium documentation where it states:
For multiple reasons, logging into sites like Gmail and Facebook using WebDriver is not recommended. Aside from being against the usage terms for these sites (where you risk having the account shut down), it is slow and unreliable.
So, the options here are:
- No, you can't use Selenium to automate Outlook (Desktop version) because Selenium automates apps in the browser.
- No, you shouldn't use Selenium to automate Outlook (outlook.com web app) because it's against their terms of service, they could block you, and they could update their site, which causes you to keep updating any automation code. In this case, it's recommended to get access to an API from Outlook to make a GET request for the information you want to verify. This will be faster, less brittle, and the most appropriate way to avoid ToS violations.