I am attempting to export the contents of my company's fairly large public folder layout (000s of folders) from Exchange Server 2010 using RDO 5.14.
I am hitting the issue that a lot of people find, in that at some point Exchange 2010 gives the error E_MAPI_TOO_BIG because the user I am using has breached the exchange store limits documented here.
The accepted solution in many cases is to call while (Marshal.ReleaseComObject(ref)>0)
on every ref and GC.Collect()
once in a while which does appear to allow the processing of more items but still doesn't allow me to get more than 500 messages in.
Some playing around with the code. It reveals the following surprising (at least to me) fact.
If I iterate over the items in a folder like this there is no problem:
for (int i = 1; i < items.Count; ++i) {
IRDOMail item = items.Item(i);
string SUCCESS = item.EntryID;
}
BUT, if I use this code sample at some point it fails (elsewhere in the code trying to access other folders) with E_MAPI_TOO_BIG:
for (int i = 1; i < items.Count; ++i) {
IRDOMail item = items.Item(i);
string FAIL = item.Subject;
}
At this point I've reached the very limit of my COM skills. It suggests to me that some part of de-referencing a COM property of a MailItem in .NET InterOp ends up grabbing a reference that I can't release. If that's the case I'm not sure how I can fix it, if at all?
Similar (but different) behaviour can be seen if I use MAPI without RDO, further suggesting that it is a quirk of MAPI (14.0)?