My inbox has just over 16,000 items in it. I have a business need to grab all the items in this inbox and compare them against another data set.
Using Outlook Interop, I was unable to get but about 5,000 items until I read this post on this site.
In short, this other post suggests to immediately place all the items from the folder into a separate generic List<MailItem>
, and it works (anyone know why?)
foreach (var itm in inbox.Items)
{
if (itm is MailItem)
{
if (!mailItemList.Contains(itm))
{
mailItemList.Add(itm as MailItem);
}
}
else
{
if (!notMailItemList.Contains(itm))
{
notMailItemList.Add(itm);
}
}
}
It was really helpful, and after inserting all the MailItems
into a generic List
, I was able to get the correct count.
I can't read all the items still. I've been able to read and get the data from just over 15,000 items. After that, I'm not entirely sure what happens, but I believe that I'm running out of memory. I do get Out Of Memory exceptions, but not all the time.
Hence, this issue has been difficult to track down. I've discovered that I can loop all the items, for example, test if an Item is a MailItem and count it as such, but I can't access data within the item.
Example: -- this will actually give correct counts
foreach (MailItem mi in mailItemList)
{
counter++;
}
Example: this will "truncate the count":
foreach (MailItem mi in mailItemList)
{
string fromAddress = string.Empty;
if (mi != null && mi.SenderEmailAddress != null && !string.IsNullOrEmpty(mi.SenderEmailAddress))
{
fromAddress = mi.SenderEmailAddress;
}
counter++;
}
The point is, that if I attempt to get any data from the List
, I can't get all the data from the inbox. In my situation, partial data is useles.
I have attempted to use additional tools. I exported the PST to a file. It's about 37 GB in size. The Redemption tool is useless. I can't even get it to work and their support is abysmal. I've tried PST .NET, while this tool actually works, it ran for about 30 minutes and then gave me an Out of Memory error.
I'm running out of hope. My next step is to attempt to use the MailSystem.NET assembiles and connect directly to the RackSpace servers, but my connections are not working (unexpected End of Stream for the IMAP4 attempt).
If anyone has a solution on how I can get all of the items from either my Outlook inbox directly or from my exported PST, I'd be very grateful.