View Single Post
  #6  
Old April 30th 09, 07:01 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Unable to cast COM object" error

You can filter or restrict on both Note and Post items in the same filter.
Obviously when you retrieve an Object that could be either you further need
to test for either Class or MessageClass to know which type to assign that
Object.

However, unless you don't have any possibility of running into custom forms
or want to exclude all custom forms you are probably best off using a filter
that checks for the MessageClass starting with "IPM.Note" or starting with
"IPM.Post". That's easiest to do using the undocumented capability of using
SQL type statements in a filter.

That filter would look something like this. The DASL property tags aren't
URL's, they are actually the DASL equivalent of "MessageClass".

"http://schemas.microsoft.com/mapi/proptag/0x001a001e" LIKE 'IPM.Note%' OR
"http://schemas.microsoft.com/mapi/proptag/0x001a001e" LIKE 'IPM.Post%'

I'd construct that using StringBuilder myself probably:

StringBuilder sb = new StringBuilder();

/mapi/proptag/0x001a001e" + @" LIKE
'IPM.Note%' OR" + @"http://schemas.microsoft.com/mapi/proptag/0x001a001e" +
@" LIKE 'IPM.Post%'");

string filter = "@SQL=" + sb.ToString();

Microsoft.Office.Interop.Outlook.Items oTestItems =
oFldr.Items.Restrict(filter);

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Emrak" wrote in message
...
I am making the assumption as of now (tell me if I'm wrong), that I can
only
process Posts and Notes separately. I thank you for your time.


Ads