I'm trying to loop through email messages in an Inbox to do some processing on them. No problems with regular email messages.. however when I try to cast one of the Items in the Inbox to an Outlook.MailItem I get an exception "Specified cast is not valid." This happens when i try to cast an Undeliverable message from my exchange server.
What type is this message? It's not an Outlook.MailItem but it looks just like any other email message.
This is how I get the other items and this works fine.
Outlook.MailItem msg = (Outlook.MailItem)ibox.Items.Item(1);
thanks for any help.