PC Review


Reply
Thread Tools Rate Thread

C# Interface into Microsoft Outlook Calendar?

 
 
Rico
Guest
Posts: n/a
 
      25th Jun 2009
From a C# program, how do I access my own Microsoft Outlook Calendar?

My ultimate goal is to add the information to my screen saver to
notify other employees where I am when not at my desk.

I assume the answer has something to do with an API (Application
Programmer Interface), but I've never used this one before.

Thanks.
 
Reply With Quote
 
 
 
 
Rico
Guest
Posts: n/a
 
      25th Jun 2009
Starting with this link:

http://stackoverflow.com/questions/9...calendar-items

I tried the following code:

------------------------------- C U T - H E R E
-------------------------------

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

------------------------------- C U T - H E R E
-------------------------------

But get an 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))."

------------------------------- C U T - H E R E
-------------------------------

For whatever it's worth, I did put into AsssmelbyInfo.cs:

[assembly: ComVisible(true)]

but I still get the exception. Why?

Any ideas, please?
 
Reply With Quote
 
Rico
Guest
Posts: n/a
 
      25th Jun 2009
Starting with this link:

http://stackoverflow.com/questions/9...tlook-calendar...

I tried the following code:

---------------- C U T - H E R E ----------------

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


---------------- C U T - H E R E ----------------

But get an 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))."

---------------- C U T - H E R E ----------------

For what it's worth, I did put into AsssmelbyInfo.cs:

[assembly: ComVisible(true)]

but I still get the exception. Why?

Any ideas, please?
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: C# Interface into Microsoft Outlook Calendar? Rico Microsoft Outlook Interoperability 0 25th Jun 2009 10:43 PM
C# Interface into Microsoft Outlook Calendar? Rico Microsoft C# .NET 1 25th Jun 2009 10:43 PM
Re: C# Interface into Microsoft Outlook Calendar? Rico Microsoft C# .NET 0 25th Jun 2009 10:39 PM
Need to build a MS Outlook like Calendar interface =?Utf-8?B?QWlyRHVzdGVyMTAx?= Microsoft Access Getting Started 0 13th Mar 2007 07:24 AM
Access to shared Calendar from Outlook Web Interface =?Utf-8?B?TWVyeWwgTWlsbGVy?= Microsoft Outlook Calendar 0 4th May 2006 04:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:39 AM.