Hello @Vinay Sharma , in order to succesfuly Authenticate an IMAP connection using OAuth client credentials with Azure AD you need to obtain an access token targeting the https://outlook.office.com/.default
scope and encode the access token using the SASL XOAUTH2 format. E.g. base64("user=" + userName + "^Aauth=Bearer " + accessToken + "^A^A")
In your code replace
store.connect("outlook.office365.com", 993, "abc@example.com",
"{
{access_token}}");
With:
store.connect("outlook.office365.com", 993, "abc@example.com", "SASL XOAUTH2 encoded access token");
Let us know if you need additional assistance. If the answer was helpful, please accept it and complete the quality survey so that others can find a solution.