I am trying to iterate through the Items collection of the Inbox folder of an account. What is the class of the Item if it is a NDR message?
Asked
Active
Viewed 472 times
1 Answers
1
ReportItem. You can see that object in OutlookSpy (I am its author): select the item, click Item button on the OutlookSpy ribbon.

Dmitry Streblechenko
- 62,942
- 4
- 53
- 78
-
Thanks. What is good way to find out the class of the item? I am now casting as each known Item type and then checking for not null. Rather inefficient. – Old Geezer Aug 24 '13 at 01:55
-
What programming language are you using? Check the Class property (exposed by all OOM objects) using late binding. It is 43 (OlObjectClass.olMail) for the MailItem objects. olReport is 46. – Dmitry Streblechenko Aug 24 '13 at 03:06
-
I am using C# and Outlook PIA. Basically how do I easily find out the type of each item in the Inbox.Items collection? Now, I cast it as MailItem, and if it is not null it is a MailItem, etc. – Old Geezer Aug 24 '13 at 04:56
-
One more question, do MailItem, ReportItem, etc, all those possible in the Items collection of Inbox, inherit from some base class (other than object)? – Old Geezer Aug 24 '13 at 13:10
-
No, MailItem and ReportItem do not share a common ancestor. You will need to use late bringing (reflection) to read the Class property exposed by both. – Dmitry Streblechenko Aug 26 '13 at 19:43
-
Thanks. By using GetType().InvokeMember I am able to Move any item to another folder. Am assuming every type has a Move method though. – Old Geezer Aug 27 '13 at 06:20
-
Yes, every item type has that method. – Dmitry Streblechenko Aug 27 '13 at 16:35