I develop an Outlook VSTO add-in in C#. I need to read existing appointments from shared calendars to see busy time slots. I have the publishing editor permission over all shared calendars and it's working with non-private appointments seamlessly.
My only problem is that CalendarFolder.Items collection does not contain appointment items having olPrivate or olPersonal Sensitivity setting. While the built-in Outlook calendar view shows these items with the little lock icon.
I understand that private appointments expose only Start and End times and it would be absolutely enough for me.
The underlying Exchange server version is 2013. We use Outlook 2013 and 2016.
Any idea what can cause this?
Thank you.
UPDATE:
Finally I found a solution for this problem by using EWS Managed API 2.0.
using Microsoft.Exchange.WebServices.Data;
// ......
ExchangeService EWSService = new ExchangeService();
EWSService.Credentials = new WebCredentials("EXCHUser", "EXCHPW");
EWSService.Url = new Uri("https://...../EWS/Exchange.asmx");
Mailbox primary = new Mailbox(Tools.MainWindow.SelectedConsultant.Email);
var calendar = Microsoft.Exchange.WebServices.Data.CalendarFolder.Bind(EWSService,
new FolderId(WellKnownFolderName.Calendar, primary));
ItemView cView = new ItemView(100);
// Limit the properties returned to the appointment's subject,
// start time, end time and sensitivity.
cView.PropertySet = new PropertySet(AppointmentSchema.Subject,
AppointmentSchema.Start,
AppointmentSchema.End,
AppointmentSchema.Sensitivity);
// Filter by sensitivity and retrieve a collection of appointments by using the item view.
String SearchFilterValue = Sensitivity.Private.ToString();
SearchFilter.IsEqualTo filter = new SearchFilter.IsEqualTo(AppointmentSchema.Sensitivity, SearchFilterValue);
FindItemsResults<Item> appointments = calendar.FindItems(filter, cView);
foreach (Appointment a in appointments)
{
if (a.Sensitivity == Sensitivity.Private)
{
// Do what you want with the matched item
}
}
// ......