A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Exception iterating thru inbox mailitems



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 20th 08, 12:44 AM posted to microsoft.public.outlook.program_addins
Stuart Parker
external usenet poster
 
Posts: 15
Default Exception iterating thru inbox mailitems

Hi

If I use a For Each to iterate through the inbox mailitems, I get the
following exception after a few items are processed:

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)).

What's going on ?

Cheers

Ads
  #2  
Old September 20th 08, 01:14 AM posted to microsoft.public.outlook.program_addins
Stuart Parker
external usenet poster
 
Posts: 15
Default Exception iterating thru inbox mailitems

OK, The item it's failing on is a Non-Delivery Report returned by Exchange
which is in the inbox.

Is there something strange about NDRs, I assume they aren't of type mailitem
then?


"Stuart Parker" wrote in message
news
Hi

If I use a For Each to iterate through the inbox mailitems, I get the
following exception after a few items are processed:

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)).

What's going on ?

Cheers


  #3  
Old September 20th 08, 01:28 PM posted to microsoft.public.outlook.program_addins
[email protected]
external usenet poster
 
Posts: 24
Default Exception iterating thru inbox mailitems

On Sep 19, 8:14*pm, "Stuart Parker" wrote:
OK, The item it's failing on is a Non-Delivery Report returned by Exchange
which is in the inbox.

Is there something strange about NDRs, I assume they aren't of type mailitem
then?

"Stuart Parker" wrote in message

news
Hi


If I use a For Each to iterate through the inbox mailitems, I get the
following exception after a few items are processed:


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)).


What's going on ?


Cheers


Their message class is "IPM.Note.NDR", so they're a sub-type of
MailItem. I'd be surprised if it wouldn't create a MailItem from one,
but I haven't tried. Either way, when iterating through a collection,
you're always best off putting the conversion from the dispatch to the
MailItem in a try/catch. If it fails, what you have can't be used as
a MailItem.
  #4  
Old September 20th 08, 03:27 PM posted to microsoft.public.outlook.program_addins
Stuart Parker
external usenet poster
 
Posts: 15
Default Exception iterating thru inbox mailitems



wrote in message
...
On Sep 19, 8:14 pm, "Stuart Parker" wrote:
OK, The item it's failing on is a Non-Delivery Report returned by
Exchange
which is in the inbox.

Is there something strange about NDRs, I assume they aren't of type
mailitem
then?

"Stuart Parker" wrote in message

news
Hi


If I use a For Each to iterate through the inbox mailitems, I get the
following exception after a few items are processed:


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)).


What's going on ?


Cheers


Their message class is "IPM.Note.NDR", so they're a sub-type of
MailItem. I'd be surprised if it wouldn't create a MailItem from one,
but I haven't tried. Either way, when iterating through a collection,
you're always best off putting the conversion from the dispatch to the
MailItem in a try/catch. If it fails, what you have can't be used as
a MailItem.


thanks!

Is there a way to pre-empt this? can I check the type of the item before I
try and cat it to a mailitem?

  #5  
Old September 20th 08, 04:23 PM posted to microsoft.public.outlook.program_addins
[email protected]
external usenet poster
 
Posts: 24
Default Exception iterating thru inbox mailitems

On Sep 20, 10:27*am, "Stuart Parker" wrote:
wrote in message

...



On Sep 19, 8:14 pm, "Stuart Parker" wrote:
OK, The item it's failing on is a Non-Delivery Report returned by
Exchange
which is in the inbox.


Is there something strange about NDRs, I assume they aren't of type
mailitem
then?


"Stuart Parker" wrote in message


news


Hi


If I use a For Each to iterate through the inbox mailitems, I get the
following exception after a few items are processed:


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)).


What's going on ?


Cheers


Their message class is "IPM.Note.NDR", so they're a sub-type of
MailItem. *I'd be surprised if it wouldn't create a MailItem from one,
but I haven't tried. *Either way, when iterating through a collection,
you're always best off putting the conversion from the dispatch to the
MailItem in a try/catch. *If it fails, what you have can't be used as
a MailItem.


thanks!

Is there a way to pre-empt this? can I check the type of the item before I
try and cat it to a mailitem?


You can do yourself what the ATL wrapper is doing for you: call
QueryInterface. But it's easier just to cast it and catch the
exception.
  #6  
Old September 22nd 08, 01:25 PM posted to microsoft.public.outlook.program_addins
Stuart Parker
external usenet poster
 
Posts: 15
Default Exception iterating thru inbox mailitems



wrote in message
...
On Sep 19, 8:14 pm, "Stuart Parker" wrote:
OK, The item it's failing on is a Non-Delivery Report returned by
Exchange
which is in the inbox.

Is there something strange about NDRs, I assume they aren't of type
mailitem
then?

"Stuart Parker" wrote in message

news
Hi


If I use a For Each to iterate through the inbox mailitems, I get the
following exception after a few items are processed:


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)).


What's going on ?


Cheers


Their message class is "IPM.Note.NDR", so they're a sub-type of
MailItem. I'd be surprised if it wouldn't create a MailItem from one,
but I haven't tried. Either way, when iterating through a collection,
you're always best off putting the conversion from the dispatch to the
MailItem in a try/catch. If it fails, what you have can't be used as
a MailItem.


It's actually of class "REPORT.IPM.Note.NDR" .. could that explain why I
can't cast it to a mailitem?

However, I can cast it to a ReportItem

Now I'm using a table object to get a list of my items, and then casting to
the correct type based on the messageclass column in the table (using
namespace.getitemfromID)


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
iterating an array Jade Outlook and VBA 1 July 9th 08 08:11 PM
Iterating Through UserProperty Values Henry Stockbridge Outlook and VBA 2 June 22nd 08 08:35 PM
Type Mismatch when iterating through eMail-folder MailItems in Outlook 2003 [email protected] Outlook and VBA 3 October 5th 07 02:45 PM
Iterating through outloook emails c_shah Outlook and VBA 1 August 10th 06 05:49 AM
How To: select mailitems from my inbox? NFR Outlook - Using Forms 1 May 16th 06 03:41 PM


All times are GMT +1. The time now is 09:25 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.