我在尝试读取Outlook日历信息的C#Windows应用程序时遇到错误,此操作以前有效,但是我认为服务器端发生了与安全相关的更改,我也看不到,也不会告诉我。
我正在使用Outlook 2010(v14.0.3129.5000)
我得到的错误是:
System.Runtime.InteropServices.COMException(0x80004005):未指定的错误(来自HRESULT的异常:0x80004005(E_FAIL))
尝试读取约会正文时发生错误:
if (oAppt.Body != null)
我可以准备好其他日历属性,而不会出现任何问题
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()
任何人都可以帮助解决为什么会发生此错误,并且如果有任何解决方法,我可以执行?
我能够与一位管理员联系,发现此特定问题是由推送到我们计算机上的组策略引起的。
该错误无助于您将方向指向该方向,但这就是问题所在
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句