我想通過他的電子郵件從我的同事處獲得某個日期範圍內的所有約會。我可以通過outlook訪問他的日曆。我只想知道他是否已經預約了「免費」,「忙碌」或「OOF」。該代碼適用於「完整詳細信息」權限,但不適用於「空閒/忙碌時間,主題,位置」權限級別。通過EWS僅通過「忙/閒時間,主題,位置」許可級別獲得來自同事的約會
我的同事不應該將權限級別更改爲「全部細節」。它應該停留在「忙/閒時間,主題,地點」是這樣的:
我有以下代碼:
private static void GetAllCalendarItems()
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
service.UseDefaultCredentials = true;
service.Url = new Uri("https://example.com/EWS/Exchange.asmx");
FolderId cfolderid = new FolderId(WellKnownFolderName.Calendar, "[email protected]");
Folder TargetFolder = Folder.Bind(service, cfolderid);
CalendarFolder calendar = CalendarFolder.Bind(service, cfolderid);
CalendarView cView = new CalendarView(DateTime.Now, DateTime.Now.AddDays(30), 5);
cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.LegacyFreeBusyStatus);
FindItemsResults<Appointment> appointments = null;
try
{
appointments = calendar.FindAppointments(cView);
}
catch (ServiceResponseException ex)
{
Debug.WriteLine("Error code: " + ex.ErrorCode);
Debug.WriteLine("Error message: " + ex.Message);
Debug.WriteLine("Response: " + ex.Response);
}
foreach (Appointment a in appointments)
{
Debug.Write("Subject: " + a.Subject.ToString() + "\t\t\t");
Debug.Write("Status: " + a.LegacyFreeBusyStatus.ToString() + "\t\t\t");
Debug.WriteLine("");
}
}
此代碼工作正常與我的電子郵件。但不是來自我的同事的。我得到下面的異常在我的try-catch塊:
Exception thrown: 'Microsoft.Exchange.WebServices.Data.ServiceResponseException' in Microsoft.Exchange.WebServices.dll
Error code: ErrorAccessDenied
Error message: Access is denied. Check credentials and try again.
Response: Microsoft.Exchange.WebServices.Data.FindItemResponse`1[Microsoft.Exchange.WebServices.Data.Appointment]
我有一個給定的權限訪問他的日程表,因爲我可以看到他的Outlook約會,所以我怎麼能獲得與地位的約會從他的同事那裏收到他的電子郵件?
您是否檢查了權限列弗你同事給你的els?或嘗試設置憑據? – Scrobi
是的,我不想用靜態證書來做,它應該與我的AD證書一起工作。我有我的同事的日曆的權限,但它也應該工作如果我沒有任何權利,因爲狀態「自由」,「忙」或「OOF」也可以在Outlook中看到,如果我對他沒有任何權限日曆。 –
找到這個[msdn文章](https://msdn.microsoft.com/en-us/library/office/dn641956(v = exchg.150).aspx)可能有所幫助。 – Scrobi