For some reason C# thinks this value might be null. Even with an IF statement saying if it is NULL also says it might be NULL. Makes no sense, that’s why I have an IF statement. Example shows the code without the IF statement.
`
using Azure.Identity;
using Microsoft.Graph;
using Microsoft.Graph.Models;
using System;
using System.IO;`
`
var allMailFolders = await graphClient.Users["[email protected]"]
.MailFolders["Inbox"]
.Messages
.GetAsync(x => {
x.QueryParameters.Top = 1;
});
graphClient.Me.MailFolders.Request().GetAsync();
string junkEmailId = "";
foreach(MailFolder folder in allMailFolders){ //This is where it says it might be NULL
if (folder.DisplayName == "Junk Email"){
junkEmailId = folder.Id;
}`
I’ve tried other ways to get these mail folders, but the result is always the same.