我得到一個C#Windows應用程序嘗試讀取Outlook日曆信息的錯誤 但以前工作但我認爲在服務器端發生的安全相關的變化,我可以看到,也不會被告知。錯誤閱讀Outlook日曆約會與C#程序
我使用Outlook 2010(v14.0.3129.5000)
有錯誤我得到的是:
System.Runtime.InteropServices.COMException(0x80004005的):未指定的錯誤(從HRESULT異常:
:0X80004005(E_FAIL))if (oAppt.Body != null)
嘗試讀取預約體時出現的錯誤10
我可以沒有問題
Microsoft.Office.Interop.Outlook.RecurrencePattern recurrencePattern;
Microsoft.Office.Interop.Outlook.NameSpace oNS;
Microsoft.Office.Interop.Outlook.MAPIFolder oCalendar;
Microsoft.Office.Interop.Outlook.Items oItems;
Microsoft.Office.Interop.Outlook.AppointmentItem oAppt;
Microsoft.Office.Interop.Outlook.Application _OutlookApplication;
try
{
_OutlookApplication = new Microsoft.Office.Interop.Outlook.Application();
oNS = _OutlookApplication.GetNamespace("MAPI");
// Get the Calendar folder.
oCalendar = oNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar);
oCalendar.Items.IncludeRecurrences = true;
// Get the Items (Appointments) collection from the Calendar folder.
oItems = oCalendar.Items;
for (Int32 x = 1; x <= oItems.Count; x++)
{
//Need to change how we are getting the appointment
//Apparently Outlook will return non-appointments in the calendar feed
try
{
oAppt = (Microsoft.Office.Interop.Outlook.AppointmentItem)oItems[x];
Console.WriteLine(oAppt.Subject);
}
catch (Exception)
{
continue;
}
if (oAppt.Body != null)
Console.WriteLine(" Calendar Body:" + oAppt.Body.ToString());
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message.ToString());
}
}
通過堆棧跟蹤我看到下面的錯誤
at Microsoft.Office.Interop.Outlook._AppointmentItem.get_Body()
任何人都可以用,爲什麼這個錯誤發生的幫助,如果有任何挖掘準備其他日曆屬性我可以執行什麼工作?
您可以使用EWS,這幫助我(仍然工作)http://stackoverflow.com/questions/3304157/error-when- i-try-to-read-update-the-body-of-a-task-via-ews-managed-api-you-m – forX 2016-12-16 18:57:19