'Access private appointments in a shared calendar from Outlook add-in
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
}
}
// ......
Solution 1:[1]
This is by design. There is nothing special about these appointments, and their properties are still accessible using Extended MAPI (C++ or Delphi). If using Redemption (I am its author) is an option (it wraps Extended MAPI and can be used from any language), its RDOAppointment object (which can be retrieved from RDOFolder) will return all available properties.
Can you see the data on the MAPI level if you look at it using OutlookSpy (I am also its author - click IMessage button or click IMAPIFolder button and open the appointments from the GetContentsTable tab)?
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 |