0

I am getting an error with a C# windows app trying to read Outlook calendar info This worked previously however I think a security related change happened on the server side that I can see nor will I be told about.

I am using Outlook 2010 (v14.0.3129.5000)

There error I get is:

System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

The error occurs when trying to read the appointment body:

if (oAppt.Body != null)

I can ready other calendar properties with no issues

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());
   }
 }

Digging through the stack trace I see the following error

 at Microsoft.Office.Interop.Outlook._AppointmentItem.get_Body()

Can anyone help with why this error is occurring and if there is any work around I can perform?

crthompson
  • 15,653
  • 6
  • 58
  • 80
user3693281
  • 97
  • 2
  • 2
  • 8
  • you can use EWS, this help me (still working) http://stackoverflow.com/questions/3304157/error-when-i-try-to-read-update-the-body-of-a-task-via-ews-managed-api-you-m – forX Dec 16 '16 at 18:57

1 Answers1

0

I was able to touch base with one of our Admins and found out this particular issue was being caused by a Group Policy that was pushed to our computer.

The error does nothing to point you in that direction but that was the issue

user3693281
  • 97
  • 2
  • 2
  • 8
  • Did you correct by changing the group policy? I have the same error. I tried other version of Interop but no change. Why we cant get the description event if we have all the other properties? – forX Dec 15 '14 at 20:52
  • Not sure what permissions they granted but they did give my account something extra and this started to work again – user3693281 Dec 17 '14 at 22:18
  • Do we know what setting needs to be changed? – David Lozzi May 13 '16 at 12:44
  • If someone find a way to do a workaround (keeping group policy), could be useful. – forX Dec 16 '16 at 16:11