I'm trying to use MS Graph API to read emails from a specific mailbox.
var client = await GetClient(); //getting a client with client id, secret
var users = await client.Users.Request()
.Filter("startswith(displayName,'roger')")
.GetAsync(); //getting the users matching a criteria
var user = users.First(); //get the first user
//log the user name, this works fine
log.LogInformation("Found user " + user.DisplayName);
//this is null
var messages = user.MailFolders?.FirstOrDefault();
I get all the correct data from the user I fetch here but the user mailFolders
property is null
.
Why is this?
We want to scan for emails in a specific mailbox and process those emails and attachments. and I thought this could be a proper way to do this. But I'm stuck on the above and the documentation on MS Graph and especially the .NET API's are so so.
Is it an authority thing, can I somehow increase the privilege of our AD application registration to get this privilege?
Or is there something else going on here?