none
Retrieving Messages from Exchange Folder from a specific date RRS feed

  • Question

  • Hi All,

    I had a  Windows Service that was using the Exchange Service API, which would sync mailboxes of selected users. With the Exchange API, I could sync a mailbox back to a designated date (mostly 365 days). I would get all of the messages from that specific date and then sync daily from the last sync date (all new messages from the original sync). This process was in place for a few years and worked well.

    I am trying to get the same process working with the graph API. However, I cannot figure out what the query parameters would be to get this process in place, that of collecting messages from a certain date. Below is what I am currently doing.

                DateTime now = DateTime.UtcNow.AddDays(-numberOfDaysBack);
                string startDate = now.ToString("yyyy-MM-ddTHH:mm:ssZ");
    
    
                var queryOptions = new List<QueryOption>()
                {
                    new QueryOption("startdate", startDate)
                };
    
    
                var graphServiceClient = new GraphServiceClient(
                    new DelegateAuthenticationProvider(x =>
                    {
                        x.Headers.Authorization = new AuthenticationHeaderValue(
                            "Bearer", res.Result.AccessToken);
    
                        return Task.FromResult(0);
                    }));
                var messages = await graphServiceClient.Users[userId].MailFolders[folderId].Messages.Request(queryOptions).GetAsync();
    

    Does anybody know the correct parameters to get the process retrieving messages from a specific date?

    Thanks,

    Tom

    Tuesday, March 3, 2020 4:44 PM