Discussion:
Programmatic Interface (API) into Microsoft Outlook Calendar
(too old to reply)
Rico
2009-06-26 21:05:21 UTC
Permalink
My goal is to access my Microsoft Outlook Calendar from a C# program.
If you know VB I can work with it.

I started with:

http://stackoverflow.com/questions/90899/net-get-all-outlook-calendar-items

and wrote the following:
---------------------------------------------------

Microsoft.Office.Interop.Outlook.Application oApp = null;
Microsoft.Office.Interop.Outlook.NameSpace mapiNamespace = null;
Microsoft.Office.Interop.Outlook.MAPIFolder calendarFolder = null;

oApp = new Microsoft.Office.Interop.Outlook.Application();
mapiNamespace = oApp.GetNamespace("MAPI");
calendarFolder = mapiNamespace.GetDefaultFolder
(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar);

foreach (Microsoft.Office.Interop.Outlook.AppointmentItem item in
calendarFolder.Items)
{
System.Console.WriteLine(item.Location);
}

---------------------------------------------------


Yesterday, I kept getting this exception at the start of the foreach
loop:

System.InvalidCastException was unhandled

Message="Unable to cast COM object of
type 'System.__ComObject' to interface
type 'Microsoft.Office.Interop.Outlook.AppointmentItem'.

This operation failed because the QueryInterface call on the COM
component
for the interface with IID '{00063033-0000-0000-C000-000000000046}'
failed due to the following error: No such interface supported
(Exception from HRESULT: 0x80004002 (E_NOINTERFACE))."

---------------------------------------------------

This morning, when I logged in, the program ran perfectly.

This afternoon, I am getting the same exception.

What is unique or special about COM that I need to know in order to
avoid these exceptions?

Is there some sort of system configuration that I need to turn on?
Something in the registry?

Thanks.
nagamalleswari
2010-08-09 11:55:10 UTC
Permalink
Post by Rico
My goal is to access my Microsoft Outlook Calendar from a C# program.
If you know VB I can work with it.
http://stackoverflow.com/questions/90899/net-get-all-outlook-calendar-items
---------------------------------------------------
Microsoft.Office.Interop.Outlook.Application oApp = null;
Microsoft.Office.Interop.Outlook.NameSpace mapiNamespace = null;
Microsoft.Office.Interop.Outlook.MAPIFolder calendarFolder = null;
oApp = new Microsoft.Office.Interop.Outlook.Application();
mapiNamespace = oApp.GetNamespace("MAPI");
calendarFolder = mapiNamespace.GetDefaultFolder
(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar);
foreach (Microsoft.Office.Interop.Outlook.AppointmentItem item in
calendarFolder.Items)
{
System.Console.WriteLine(item.Location);
}
---------------------------------------------------
Yesterday, I kept getting this exception at the start of the foreach
System.InvalidCastException was unhandled
Message="Unable to cast COM object of
type 'System.__ComObject' to interface
type 'Microsoft.Office.Interop.Outlook.AppointmentItem'.
This operation failed because the QueryInterface call on the COM
component
for the interface with IID '{00063033-0000-0000-C000-000000000046}'
failed due to the following error: No such interface supported
(Exception from HRESULT: 0x80004002 (E_NOINTERFACE))."
---------------------------------------------------
This morning, when I logged in, the program ran perfectly.
This afternoon, I am getting the same exception.
What is unique or special about COM that I need to know in order to
avoid these exceptions?
Is there some sort of system configuration that I need to turn on?
Something in the registry?
Thanks.
--
______________________________________
Posted from http://outlook-center.com
Outlook forums, articles, tips.
Loading...