unable to get the emails from outlook by using graph api get method
public List<Message> GetAllMails()
{
List<Message> mails = new List<Message>();
//var result = graphClientV1.Me.Messages.Request().GetAsync();
//IUserMessagesCollectionPage currentPage = result.Result;
IUserMessagesCollectionPage currentPage = graphClientV1.Me.Messages.Request().GetAsync().Result;
while (currentPage != null)
{
foreach (var mail in currentPage)
{
try
{
mails.Add(mail);
}
catch (Exception) { }
}
currentPage = (currentPage.NextPageRequest != null) ? currentPage.NextPageRequest.GetAsync().Result : null;
}
return mails;
}
i want to get the all mails from outlook.
error:
NullReferenceException: Object reference not set to an instance of an object.
1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task
1.get_Result() Do you have any specific recommendations on what I should be looking for or any particular part of the code that might be causing this issue?