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?