View Single Post
  #4  
Old April 30th 09, 04:39 PM posted to microsoft.public.outlook.program_addins
Emrak
external usenet poster
 
Posts: 6
Default Unable to cast COM object" error

As an addendum to my last post, I've learned that "Post" is the object type
I'm looking for. As such, I'll demonstrate my current solution for posterity.
I'm using the KISS method here. This works, but I can't determine how, in the
context of "string filter" below, how I'm supposed to code "OR" below. For
instance, MessageClass = NOTE OR POST.




//instanciate variables
Microsoft.Office.Interop.Outlook.Application oOutlook;
Microsoft.Office.Interop.Outlook.NameSpace oNs;
Microsoft.Office.Interop.Outlook.MAPIFolder oFldr;
int iAttachCnt = 0;

oOutlook = new Microsoft.Office.Interop.Outlook.Application();
oNs = oOutlook.GetNamespace("MAPI");

//are there any emails to process?
oFldr = oNs.Folders["Public Folders"].Folders["Test"]

if (oFldr.Items.Count 0)
{

//cycle through each email, filtering out only messages and posts, no
calendars or tasks

string filter = "[MessageClass] = \"IPM.Note\"";

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