The value for the variable scopes
is wrong. You need to set this to the Microsoft Graph permission scopes necessary to read email messages from all mailboxes. Because you're using application permissions, this permission request should be made in the Azure Portal rather in your code.
First, request the Mail.Read
application permission.
Then grant that permission.
Then set the value of scopes as shown below. This tells Microsoft Graph to use the permissions configured in the Azure Portal.
var scopes = new[] { "https://graph.microsoft.com/.default" };
Here are links to a couple Microsoft Learn training paths that can give you some more foundational training on how to use Microsoft Graph.