Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4104364
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:06:32+00:00 2026-05-20T21:06:32+00:00

I have a C# application, in which I access outlook through the Office PIAs

  • 0

I have a C# application, in which I access outlook through the Office PIAs in order to parse appointments. In my application, when I create my outlook object, a new outlook process is created in the task manager. When I close my application, I also quit the outlook object. This shuts down the outlook process in my task manager.

My problem is, when the user is also interacting with outlook. Specifically, if the user has outlook opened, when my program closes, my program also closes that user’s outlook program. Experimenting with opening outlook both manually and with my program, while watching the task manager, it seems that only one instance of outlook can ever be running at the same time, and both the user and my program then accesses that same instance, so when I close outlook from my program, I also shut down the user’s program.

Strangely enough, the reverse is not the case. If the user shuts down outlook, while my program runs, his window will disappear, but the outlook process will not shut down, and my program can still continue. It is as if the window is only a client of the outlook process, although there is no separate process for the window. Is there a way for me to see, if my program is the only one using the outlook process, or if there are any “user window clients” open, so I can avoid shutting down outlook, when it is still in use?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T21:06:33+00:00Added an answer on May 20, 2026 at 9:06 pm

    I found a solution myself. I turns out that outlook keeps track of how many explorers are open on it. Reaching zero explorers does not cause a shutdown of the process, but it indicates that no user has any normal outlook window open, so the process can be safely shut down. In my project I have a single class which accesses outlook. My solution is to test for zero explorers in the destructor of that class (the following code assumes “using Outlook = Microsoft.Office.Interop.Outlook;”):

    ~OutlookAccessor()
    {
        try
        {
            Outlook.Application app = new Outlook.Application();
            if (app.Explorers.Count == 0)
            {
                ((Outlook._Application)app).Quit();
            }
            System.Runtime.InteropServices.Marshal.ReleaseComObject(app);
        }
        catch (System.Runtime.InteropServices.COMException)
        {
            ; // nevermind, we're only trying to free the Outlook COM object, and the most probable cause for this exception is that office is not installed.
        }
    }
    

    Of course, you have to be careful to close all explorers you use in your code, or the solution will not work, e.g.:

    private void AccessOutlook(Outlook.MAPIFolder topfolder)
    {
        Outlook.Explorer explorer = null;
        try
        {
            explorer = topFolder.GetExplorer();
            ... // do stuff with the explorer
        }
        finally
        {
            if (explorer != null)
            {
                ((Outlook._Explorer)explorer).Close();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an application which converts Excel files to Access databases. During conversion
I have an Access 2002 application which links an Oracle table via ODBC with
I have a layered application in Java which has a multi thread data access
In an application we are developing, I have access to a database table which
I have a jsfiddle application which you can access here . Now when you
I would like to have an application which either loads or saves data through
I have an application which uses offline_access to get permanent access to different pages.
I have created an application which reads ms access database file (test.accdb). When i
I have a window application which tries to connect a MS Access file which
I have a application which you can access here . If you open the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.