Didier Levy
Didier Levy

Reputation: 3453

How to read Outlook folder with a LINQ query?

I need help or sample code in VB.NET to read a specified outlook folder that is not the inbox or a subfolder of inbox

Say folder name is "foo", how can I rerieve emails with a LINQ query, possibly adding where clause(s) for the from, to, date, subject or body content.

Thanks :-)

Upvotes: 0

Views: 1185

Answers (2)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66341

No offense, but when you have a hammer, everything looks like a nail :-) Why does it need to be LINQ? It might look neat in you source code, but it can bring your application down to its knees - if you need any kind of restriction, use the native methods whenever you can. In your case, that would be Items.Find/FindNext/Restrict. If you need to access an arbitrary folder, use the Namespace.Folders collection – it contains top level folders from all stores. If the folder is on the same level as the Inbox, use Inbox.Parent.Folders collection.

Upvotes: 2

John Babb
John Babb

Reputation: 951

You can use the following.

http://www.nuget.org/packages/scipbe.common.office/

Add it to your project and you can use linq like syntax with outlook.

Also

http://programmersunlimited.wordpress.com/2011/01/08/linqqer-exposing-linq-extensions-on-non-ienumerableiqueriable-collections/

Upvotes: 0

Related Questions