Hi
There are multiple posts about the same topic in the forum. Did you try following that guidance?
Get mails from shared mailbox returns AccessDenied - Help / Activities - UiPath Community Forum
Microsoft o365 Get Mail / Send Mail errors - Help / Studio - UiPath Community Forum
Many more…