InfiniTec - Henning Krauses Blog

Don't adjust your mind - it's reality that is malfunctioning

Working with the Recurrence pattern of Exchange 2007

One of the more difficult tasks with Exchange Web Services is coping with the recurrence pattern of an appointment or task item. Because of the limitations of WSDL and/or the proxy generator of Visual Studio, you end up with a RecurrenceType class which has two properties describing the recurrence of the element with such descriptive names as Item and Item1. To make things worse, the Microsoft did decide not to use enumerations to distinguish between different recurrence pattern types, but uses a unique type for each. Because this can be quite complex, I created this class diagram from the proxy class generated by Visual Studio:


Classdiagram with all the recurrence related types (click to enlarge)

The RecurrenceType type is used both, for appointments and tasks. But on appointments, you can't use the RegeneratingPatternBaseType and its descendants, because those are not supported by Outlook.

Creating a RecurrenceType structure is relatively straigt forward. You just take the appropiate types and fill the properties. Examining an existing structure is different: Since there is no enumeration, you'll have to use a bunch of instanceis type commands, or better yet, use the as operator (TryCast in Visual Basic).

    1 NumberedRecurrenceRangeType numberedRange = recurrence.Item1 asNumberedRecurrenceRangeType;

    2 EndDateRecurrenceRangeType endDateRange = recurrence.Item1 asEndDateRecurrenceRangeType;

    3 NoEndRecurrenceRangeType noEndDate = recurrence.Item1 asNoEndRecurrenceRangeType;

    4 

    5 if (numberedRange != null)

    6 {

    7     // Do something here

    8 }

    9 elseif (endDateRange != null)

   10 {

   11     // Do something here

   12 }

   13 elseif (noEndDate != null)

   14 {

   15     // Do something here                   

   16 }

In this example, the recurrence variable holds an instance of the RecurrenceType class.


Technorati:

Posted by Henning Krause on Tuesday, November 6, 2007 12:00 AM, last modified on Tuesday, November 6, 2007 12:00 PM
Permalink | Post RSSRSS comment feed