P
Peter Baranyi
Hi,
I am writing a c# appl. what accesses all mails in the Outlook Inbox, it
collects the server's e-mail addresses and moves the item to a folder. So
the inbox has to be empty after this program runs, all items should be in
the folder. In the test environment I have no problem, but in production on
some mails I get the following error:
System.InvalidCastException: Unable to cast COM object of type
'System.__ComObject' to interface type
'Microsoft.Office.Interop.Outlook.MailItem'. This operation failed because
the QueryInterface call on the COM component for the interface with IID
'{00063034-0000-0000-C000-000000000046}' failed due to the following error:
No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE)).
Naturally these mails will stay in the Inbox. Now, when I rerun my appl.,
most of these mails are moved, but on some I got the same exception.
The line what crashes is the second from this snipet:
Outlook.MailItem olMail = null;
olMail = (Outlook.MailItem)oItems;
I know, that on System messages, Appointments, etc. this type conversion
will raise an exception, but this is different, since on consequental runs
the appl. raises on different mails.
Can anyone help how can I avoid this problem?
Thanks:
Peter
I am writing a c# appl. what accesses all mails in the Outlook Inbox, it
collects the server's e-mail addresses and moves the item to a folder. So
the inbox has to be empty after this program runs, all items should be in
the folder. In the test environment I have no problem, but in production on
some mails I get the following error:
System.InvalidCastException: Unable to cast COM object of type
'System.__ComObject' to interface type
'Microsoft.Office.Interop.Outlook.MailItem'. This operation failed because
the QueryInterface call on the COM component for the interface with IID
'{00063034-0000-0000-C000-000000000046}' failed due to the following error:
No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE)).
Naturally these mails will stay in the Inbox. Now, when I rerun my appl.,
most of these mails are moved, but on some I got the same exception.
The line what crashes is the second from this snipet:
Outlook.MailItem olMail = null;
olMail = (Outlook.MailItem)oItems;
I know, that on System messages, Appointments, etc. this type conversion
will raise an exception, but this is different, since on consequental runs
the appl. raises on different mails.
Can anyone help how can I avoid this problem?
Thanks:
Peter