Connecting to Microsoft Exchange Online is very straightforward if you remember the steps. This is just a Quick Step-by-step on how to connect after the initial configurations were done.
If you have not connected to EXO before I suggest you work through the below Articles and install EXO V2
If you connect to different Environments use the below link:
How to Connect
Open a PowerShell console in Administration Console. Once open use the following command to Connect:
Connect-ExchangeOnline -UserPrincipalName AdminMail@yourdomain.com
Once your password is verified it will take you to the MFA Console where it will request your second Verification.
Once the Connection is done you can run you code required. Once done remember to disconnect the Session.