So far I'm able to get the next x events (without recurring events). Code:
private SPListItemCollection GetNextEvents(SPList eventCalendar)
{
DateTime currentDateTime = DateTime.Now;
string currentDateTimeString = SPUtility.CreateISO8601DateTimeFromSystemDateTime(currentDateTime);
SPQuery query = new SPQuery();
query.RowLimit = 3;
query.ExpandRecurrence = true;
query.Query = "<Where>" +
"<And>" +
"<Geq>" +
"<FieldRef Name='EndDate' />" +
"<Value Type='DateTime' IncludeTimeValue='True'>" +
currentDateTimeString +
"</Value>" +
"</Geq>" +
"<Geq>" +
"<FieldRef Name='EventDate' />" +
"<Value Type='DateTime' IncludeTimeValue='True'>" +
currentDateTimeString +
"</Value>" +
"</Geq>" +
"</And>" +
"</Where>" +
"<OrderBy>" +
"<FieldRef Name='EventDate' />" +
"</OrderBy>";
SPListItemCollection itemColl = eventCalendar.GetItems(query);
return itemColl;
}
Setting query.ExpandRecurrence = true
didn't help. I also tried the solution suggested here. Somehow I can't get it working with recurring events. For the following example I'd like to get the 2nd and 3rd "OK Repeating Event" and the "OK1" event since it starts earlier than "OK2"