0

I am new to Outlook object model. I want to trap some events like selectionchange events etc. What I found that in the selection object it returns the system.object. I have to do type checking for each item type. Not sure if there is any better way to do this.

I don't want to do type checking every time.

Ashwin

2 Answers2

0

As far as I know there is no base class for outlook message item

Check this out http://outlookitemwrapper.codeplex.com/.

You can use this wrapper. Hope this would be helpful

Atul Sureka
  • 3,085
  • 7
  • 39
  • 64
0

Why not use late binding and check the Class property? Every Outlook object exposes it.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • Won't that require type checking? I do not want to do type checking for each class. is there any sample code available? – user1188933 Feb 04 '12 at 12:32
  • How late binding would work if there is no base class with different message properties & methods. According to http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook._mailitem.class.aspx Class returns enum. I can use the 'is' operation for type checking. That is not the issue. I want to support different message types, problem is I do not want long if-else condition to check the message type. – user1188933 Feb 04 '12 at 12:39
  • Declare the item as a generic object and use GetType() to invoke any method or property. – Dmitry Streblechenko Feb 24 '12 at 17:08