I want to list all Outlook appointment times in a specific time range and I am only interested in start and end time of the appointments.
I'm using this code so far:
DateTime startTime = DateTime.Now.AddDays(2);
DateTime endTime = DateTime.Now.AddDays(3);
var outlookApplication = new Outlook.Application();
Outlook.NameSpace outlookNamespace = outlookApplication.GetNamespace("MAPI");
var recip = outlookNamespace.CreateRecipient("<valid contact>");
if (recip.Resolve())
{
var calendarItems = outlookNamespace.GetSharedDefaultFolder(recip, OlDefaultFolders.olFolderCalendar).Items;
calendarItems.IncludeRecurrences = true;
var filter = String.Format("[Start] >= '{0}' And [End] < '{1}'", startTime.ToShortDateString(), endTime.ToShortDateString());
calendarItems.Sort("[Start]");
calendarItems = calendarItems.Restrict(filter);
var result = calendarItems.Cast<AppointmentItem>().Select(x => x);
}
The code retrieves nearly all appointments, but not the private ones. How can I get the private appointments too?