This library simplifies the creation of recurring Outlook AppointmentItems using standard iCalendar recurrence patterns. It also enables the retrieval of recurrence pattern strings from existing Outlook recurring AppointmentItems.
License
—
Deps
0
Install Size
—
Vulns
✓ 0
Published
Jan 21, 2025
$ dotnet add package MZOutlookAppointmentTools.iCalendarToolsThis library simplifies the creation of recurring Outlook AppointmentItems using standard iCalendar recurrence patterns. It also enables the retrieval of recurrence pattern strings from existing Outlook recurring AppointmentItems. Currently the library provides some tools to parse,generate and compare iCalendar recurrence rules for Outlook appointment items
AppointmentItem aItem = (AppointmentItem)ApplicationInstance.CreateItem(OlItemType.olAppointmentItem);
string pattern = "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR";
RecurrenceStringTools.SetRecurrencePattern(pattern, aItem, itemStart);
var recPattern = aItem.GetRecurrencePattern();
//Expected values:
// recPattern.RecurrenceType == OlRecurrenceType.olRecursWeekly
// recPattern.DayOfWeekMask == OlDaysOfWeek.olMonday | OlDaysOfWeek.olTuesday | OlDaysOfWeek.olWednesday | OlDaysOfWeek.olThursday | OlDaysOfWeek.olFriday
// recPattern.Instance == 0
// recPattern.Interval == 1
AppointmentItem aItem = (AppointmentItem)ApplicationInstance.CreateItem(OlItemType.olAppointmentItem);
var occ = aItem.GetRecurrencePattern();
occ.RecurrenceType = OlRecurrenceType.olRecursDaily;
occ.Interval = 1;
aItem.Save();
var item = RecurrenceStringTools.GetRecurrenceString(aItem); // "FREQ=DAILY;INTERVAL=1"
string pattern1 = "FREQ=WEEKLY;BYDAY=MO,TU,WE";
string pattern2 = "FREQ=WEEKLY;BYDAY=TU,WE,MO";
var areEqual = RecurrenceStringTools.AreEqual(pattern1, pattern2);// true
More samples could be found in the test project.
olRecursWeekly as olRecursMonthNth requires the instance field to be set to a value from 1 to 5. So when it is converted back to recurrence rule the value would be simply "FREQ=WEEKLY;INTERVAL=1;BYDAY=FR" (Check these tests: Combo_MonthlyNthSetPos_Existence1 and Combo_MonthlyNthSetPos_Existence2 in RecurrenceStringToolsTest). Moreover, whenever we get the recurrence pattern from an AppointmentItem with olRecursMonthNth, we always include the "BYSETPOS".