Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there,
I can use the code below to get the view of emails with attachments:

C#
Outlook.Folder control.Context;
string query ="urn:schemas:httpmail:hasattachment = 1";
oFolder.CurrentView.Filter = query;
oFolder.CurrentView.Apply();

How can I output the emails in the view to Outlook.Items?

I tried it below. I can get all Unread items:
C#
Outlook.Items emails  = oFolder.Items;
emails  =emails.Restrict("[Unread]=true")

How can I use Restrict to filter emails with attachments out in Outlook?

Thanks in advance.
Posted
Updated 24-Aug-15 7:58am
v2

1 solution

 
Share this answer
 
Comments
Laohutu 25-Aug-15 1:25am    
Thanks, Maciej. hasattachments is the keyword in Search Contextual Tab as you mentioned in Better Searching in Outlook 2010. My question is how can I implement it in C# using Restrict as I did for Unread above?
Maciej Los 25-Aug-15 1:47am    
Follow the link (How to...) to find out.
Laohutu 26-Aug-15 9:24am    
Finally solved: GetTable from table view, then use EntryID in the table to get mailitem through:
ThisAddIn.currentExporer.Session.GetItemFromID(nextRow["EntryID"]);
Maciej Los 26-Aug-15 15:10pm    
So, post it as answer and accept it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900