Search code examples
outlookoutlook-addinoutlook-redemption

Possible ways to optimize batch Outlook appointment processing with MAPITable


I'm working in a component that syncs our own appointment data with the ones in a selected calendar folder in Outlook.

The first time when our appointments sync to Outlook, the ID of our appointment is stored in the user properties of the newly created Outlook appointment.

Therefore, before syncing each appointment to Outlook, our code has to check if there is already an appointment in Outlook that has their ID. The code is currently looping through the Folder.Items collection and look into the UserProperties of each one of them, this is obviously very slow.

I found this stackoverflow question, which suggests that I can query the MAPITable to filter out appointments that has no user properties first.

However, as more and more appointments are synced to Outlook overtime, the filtered result would become pretty big too.

Does anybody know if there is any faster way to go through user properties of all appointments in an Outlook folde?


Solution

  • I had a similar problem of filtering Appointments using a UserProperty say 'MyUserProperty' of olText type. I used a DASL query which filtered the Folder Items using UserProperty.

    string myPropertyValue = "SomeID";
    filter = "@SQL=\"http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/MyUserProperty/0x0000001F\" = '" + myPropertyValue + "' ";
    filteredAppointment = myFolderItems.Find(filter);
    

    MSDN Documentation : Filtering a Custom Field