Running out of memory in Automation

  • Thread starter Anker Berg-Sonne
  • Start date
A

Anker Berg-Sonne

I use C# and Interop to automate Outlook. It works fine,
except when I access a large number of items I get an out
of memory error. The code is simple:

using MSOutlook=Microsoft.Office.Interop.Outlook;
Outlook=new MSOutlook.Application();
MSOutlook.NameSpace NameSpace=Outlook.GetNamespace("MAPI");

and then the offending snippet:

MSOutlook.MailItem MailItem=NameSpace.GetItemFromID
(ThisItem.ID,ThisItem.StoreID) as MSOutlook.MailItem;
if (MailItem==null)
{
...
}
else
MailItem.Close(0);

The snippet is inside a loop that checks whether Items
that I have registered in my code still exist in Outlook.
If I have a large number of items registered in my
application it eventually fails with an out of COM memory
error.

TIA/Anker
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top