.NET Guideline

    • Given certain internal limitations of Outlook Express and Windows Mail, the best way to work is to have the fewest possible amount of references to OEAPI objects.
    • On each scope, every time an OEFolder and an OEMessage is not used anymore, call Marshal.ReleaseComObject() method from the System.Runtime.InteropServices namespace to release it.

Otherwise objects are not released instantly by the .NET framework, the internal limit for the amount of possible handled objects is reached and different problems occur.

  • It is better to use just one OEFolderManager.
  • It is better to use just one OEAPIObj for using the objects' IDs (i.e. toolbars IDs, buttons IDs, menu items IDs, etc.).
  • As soon as OEAPIObj objects (OEToolbar, OEButton, etc.) are no longer used, assign null/nothing to them.
  • On OnShutDownOEAPI() release every OEAPI object except OEAPIInit, and, at the end, call for the Garbage Collector twice:

GC.Collect()

GC.WaitForPendingFinalizers()

GC.Collect()

GC.WaitForPendingFinalizers()