Hello. Is your app registered with application permissions (not delegated) and if MailboxItem.ImportExport.All has been granted admin consent in Entra ID?
Also, check if an Application Access Policy is restricting your app. In PowerShell:
Connect-ExchangeOnline
Get-ApplicationAccessPolicy
Test-ApplicationAccessPolicy -Identity "<target mailbox>" -AppId "<your app ID>"
If it shows AccessDenied, your app isn’t allowed to touch that mailbox. Add the mailbox to the security group defined in the policy, or temporarily remove the restriction.