Determine if Exchange has finished initial synch with .ost file in Outlook

Nick Connor 1 Reputation point
2021-04-27T16:20:39.98+00:00

Is it possible to use Outlook Interop to determine if a user's .ost file has finished it's initial sync with Exchange? Specifically, I want to know if a user's contact folders have been completely populated before iterating through the contacts. Thank you!

Outlook | Windows | Classic Outlook for Windows | For business
Developer technologies | C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Timon Yang-MSFT 9,606 Reputation points
    2021-04-28T03:14:20.07+00:00

    You can try to use code to get the contact folder in the local file, and then use another piece of code to get the contact folder on the server and compare them.

            public static void GetContactLocal()  
            {  
                Microsoft.Office.Interop.Outlook.Items OutlookItems;  
                Microsoft.Office.Interop.Outlook.Application outlookObj;  
                MAPIFolder Folder_Contacts;  
      
                outlookObj = new Microsoft.Office.Interop.Outlook.Application();  
                Folder_Contacts = (MAPIFolder)outlookObj.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts);  
                OutlookItems = Folder_Contacts.Items;  
            }  
            public static void GetContactOnLine()  
            {  
                ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);  
                service.Credentials = new WebCredentials("******@outlook.com", "password");  
                service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");  
      
                Mailbox mb = new Mailbox("******@outlook.com");  
                FolderId fid = new FolderId(WellKnownFolderName.Inbox, mb);  
                // The search filter to get unread email.  
      
                ItemView view = new ItemView(100);  
      
                FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Contacts, view);  
            }  
    

    The Nuget packages I use: Microsoft.Office.Interop.Outlook and Microsoft.Exchange.WebServices.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.