When reading calendar appointments from Outlook, there's an option called "IncludeRecurrences" that should add all future recurrences to the list of items. For example: if I have a recurring appointment that happens every Wednesday, when my list of appointments return, I should see a future entries for my Wednesday appointment.
This works great using the Office.Interop, but when I switch my code to NetOffice, this feature doesn't work correctly. It will not create the future recurrences, therefore my list is missing entries all recurrences. My work-around is to find all recurrences, determine when they happen, and manually create them.
Would it be possible to make this work similar to the Office.Interop?
Here is my code:
public List<Appointment> GetAppointmentsInRange()
{
var result = new List<Appointment>();
Items OutlookItems = outlookCalendar.Items;
OutlookItems.IncludeRecurrences = true;
OutlookItems.Sort("[Start]", Type.Missing);
if (OutlookItems != null)
{
DateTime min = DateTime.Now.AddDays(-Settings.CalendarDaysInThePast);
DateTime max = DateTime.Now.AddDays(+Settings.CalendarDaysInTheFuture + 1);
string filter = "[End] >= '" + min.ToString("g") + "' AND [Start] < '" + max.ToString("g") + "'";
var filteredAppoinments = OutlookItems.Restrict(filter);
foreach (AppointmentItem ai in filteredAppoinments)
{
result.Add(GetOutlookAppointment(ai));
}
}
return result;
}
This works great using the Office.Interop, but when I switch my code to NetOffice, this feature doesn't work correctly. It will not create the future recurrences, therefore my list is missing entries all recurrences. My work-around is to find all recurrences, determine when they happen, and manually create them.
Would it be possible to make this work similar to the Office.Interop?
Here is my code:
public List<Appointment> GetAppointmentsInRange()
{
var result = new List<Appointment>();
Items OutlookItems = outlookCalendar.Items;
OutlookItems.IncludeRecurrences = true;
OutlookItems.Sort("[Start]", Type.Missing);
if (OutlookItems != null)
{
DateTime min = DateTime.Now.AddDays(-Settings.CalendarDaysInThePast);
DateTime max = DateTime.Now.AddDays(+Settings.CalendarDaysInTheFuture + 1);
string filter = "[End] >= '" + min.ToString("g") + "' AND [Start] < '" + max.ToString("g") + "'";
var filteredAppoinments = OutlookItems.Restrict(filter);
foreach (AppointmentItem ai in filteredAppoinments)
{
result.Add(GetOutlookAppointment(ai));
}
}
return result;
}