PDA

View Full Version : .NET Interop Outlook Filter mails with attachment/s


JygzIsHere
04-01-2009, 04:26 AM
Hi,

I want to retrieve all items from outlook inbox that has one or more attachments.


My current code is:

Outlook.Application objO = new Outlook.Application();
Outlook.NameSpace objNS = objO.GetNamespace("mapi");
objNS.Logon("profilename", "password", false, true);
Outlook.MAPIFolder folderInbox = objNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
Outlook.Items inboxItems = folderInbox.Items;
inboxItems = inboxItems.Restrict("Count([Attachments]) > 0");


But the restrict statement is not working. Is anyone here how to do it?

Thanks.