I am using the Office object model to retrieve my calendar items from Outlook. I want to use the Restrict() method to only get today's appointments. I also want to include the single instance of all recurring appointments (i.e. not all recurrences - just those today).
With the below code, I get many (but not all) recurring items like birthdays regardless of the date. I also get various other appointments - but not those for today.
I've tried different formats for the date, including 2013-07-25 00:00:00, without luck. I've researched the net, and tried to copy examples from VBA scripts - no luck.
Appreciate any ideas from others' who have done this.
var outlook = new Application();
var calendar = outlook.GetNamespace("MAPI").GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
DateTime today = DateTime.Today, tomorrow = today.AddDays(1);
const string DateFormat = "dd/MM/yyyy HH:mm";
string filter = string.Format("[Start] >= '{0}' AND [Start] < '{1}'", today.ToString(DateFormat), tomorrow.ToString(DateFormat));
var todaysAppointments = calendar.Items.Restrict(filter);
// todaysAppointments.IncludeRecurrences = true;
todaysAppointments.Sort("[Start]");
Mddyy h:mm tt
? From here: msdn.microsoft.com/en-us/library/office/… – Alden