簡體   English   中英

使用C#程序讀取Outlook日歷約會時出錯

[英]Error Reading Outlook Calendar Appointment with C# program

我在嘗試讀取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()

誰能幫助您解決為什么會發生此錯誤,並且我可以執行任何工作?

我能夠與一位管理員聯系,發現此特定問題是由推送到我們計算機上的組策略引起的。

該錯誤並不能將您指向該方向,但這就是問題所在

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM