Question

I am developing a standalone Outlook WPF application in C#. What I am trying to do is have the program monitor a public folder for any incoming mail and notify the users of any mail arrival.

I've successfully done this but I feel the manner in which I'm doing it is kludgey. Essentially I'm building a collection of MailItems and my program, via a Timer, re-scans the Public Folder for any new mail.

What I'm wondering is, is there any way to bind a collection directly to a MAPIFolder or MAPIFolder.Items. I've actually been able to set the Listbox.ItemsSource to a Outlook.Items object, but it just shows (SysCom.Object) as listbox items. So I feel like this is possible but I'd need some way to tell the Listbox to only show MailItems (as well as the appropriate binding path to the Mailitem's Subject field).

I guess what I'm ultimately trying to do is "mirror" an Outlook folder instead of copying items out of it into some other list object.

Was it helpful?

Solution

There is no way to bind in the same way you'd bind to a recorset, but what you need to do is monitor events on that folder (Items.ItemAdd/ItemChange/ItemRemove).

Also, do not load all items in a folder - besides being extermely inefficient, you can run out of RPC channels limit (enforced by Exchange). Only load enough items to dispaly to the end user. Other items need to be loaded as the user scrolls.

On the low level, Outlook uses MAPI tables that do not require to open each item as a separate object. Extended MAPI cannot be used from .Net languages, but you can either use the MAPITable object in Redemption (http://www.dimastr.com/redemption/mapitable.htm) or the Table object in Outlook 2007 and up (http://msdn.microsoft.com/en-us/library/office/bb176406(v=office.12).aspx).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top