Dmitry
Dmitry

Reputation: 91

How to restrict all outlook appointments (including recurring) by property value using C#

How to restrict all outlook appointments (including recurring) by property value using C#. I use filter = "@SQL=(http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/TestName IS NOT NULL)" (where TestName - property name) and set calendarItems.IncludeRecurrences = true; but I get only simple appointments results

Upvotes: 1

Views: 356

Answers (1)

Eugene Astafiev
Eugene Astafiev

Reputation: 49455

To retrieve all Outlook appointment items from the folder that meets the predefined condition, you need to sort the items in ascending order and set the IncludeRecurrences to true. You will not catch recurrent appointments if you don’t do this before using the Restrict method.

    item = resultItems.GetFirst();
    do
    {
       if (item != null)
       {
           if (item is Outlook._AppointmentItem)
           {
               counter++;
               appItem = item as Outlook._AppointmentItem;
               strBuilder.AppendLine("#" + counter.ToString() +
                                     "\tStart: " + appItem.Start.ToString() +
                                     "\tSubject: " + appItem.Subject +
                                     "\tLocation: " + appItem.Location);
           }
           Marshal.ReleaseComObject(item);
           item = resultItems.GetNext();
       }
   }
   while (item != null);

You may find the following articles helpful:

Upvotes: 0

Related Questions