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.