'How to get all appointments including the private ones?

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?



Solution 1:[1]

Outlook always filters out private appointments form the shared folders even if they are perfectly accessible using MAPI. If using Redemption (I am its author) is an option, you can use RDOFolder.GetActivitiesForTimeRange - it returns private appointments.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1