Question

I have a c# forms application witch i connect to outlook.

The program processes incoming mail, and should run stable during the day. The problem is that the program becomes unresponsive after a view hours, without a obvious reason.

I'm trying to log exceptions, but it just becomes unresponsive in the production environment. Any idea how to resolve this issue?

The program has some class variables:

Outlook.Application olApp;
Outlook.NameSpace olSession;
Outlook.MAPIFolder olInbox;
Outlook.Items olInboxItems

I connect outlook:

private void InitOutlook()
{

    if (olApp == null)
        olApp = new Outlook.Application();

    olSession = olApp.GetNamespace("MAPI");
    olInbox = olSession.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);

    olInboxItems = olPlanonIn.Items;
    olInboxItems.ItemAdd += new Outlook.ItemsEvents_ItemAddEventHandler(InboxItemAdded);

}

Eventhandler for processing mails

private void InboxInItemAdded(object itm)
{
// process my mail
}
Was it helpful?

Solution

I had similar issues in a Interop-PowerPoint scenario. I never found the exact reason, but a likely supsect is the number of open COM-Objects. Are you releasing all Objects properly?

Have a look at this thread for details: How do I properly clean up Excel interop objects?

As a last resort you could implement a watcher thread which restarts your process. Not nice, but it may "solve" the problem.

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