Hello,
I am wondering, if there is a method provided by Appointment or CalendarInfo to get the next / last occurrence of an appointment. If there is no built-in function, how can I achieve this?
In detail: I have an Appointment object, that has a recurrence. I want to get a new Appointment object (or at least a DateTime), that reflects the next or last occurence of the recurring appointment.
Any ideas on this topic are highly appreciated.
I found a way to get all occurrences of an recurring appointment by adding the recurring appointment to a new CalendarInfo and using the GetAppointmentsInRange method. Then, to get the last occurrence, I iterate through the AppointmentSubsetCollection. The C# code looks like this. Please note, that I am only interested in the DateTime of the last occurrence.
calinfo.Appointments.Add(app);AppointmentsSubsetCollection apps = calinfo.GetAppointmentsInRange(calinfo.MinDate, calinfo.MaxDate);DateTime dt = app.StartDateTime;foreach (Appointment a in apps){ if (a.StartDateTime > dt) dt = a.StartDateTime;}