You cannot access Inactive mailboxes programmatically, the only way would be via eDiscovery/Content search. Or recover/restore the inactive mailbox first: https://learn.microsoft.com/en-us/purview/restore-an-inactive-mailbox
Invalid License Error When Accessing Inactive Soft Deleted Mailboxes in Exchange Online
An exception "Mailbox 'x' doesn't have a valid license" occurs while trying to access inactive soft deleted mailboxes.
A mailbox with an M365 retention policy (Purview) was deleted and converted to an inactive mailbox. It's verified that the mailbox has IsSoftDeleted
and IsInactiveMailbox
properties set to true in PowerShell.
However, when creating the ExchangeServiceWrapper
to access the content, an internal server error arises: "The operation failed. Mailbox 'xx' doesn't have a valid license."
What could be the reason for this error? It is understood that the license gets revoked when a user is deleted, so why is there an invalid license error?