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

  • Home
  • SEARCH
  • 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 4050296
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:03:08+00:00 2026-05-20T14:03:08+00:00

I have a C# project, where I would like to access MS outlook, if

  • 0

I have a C# project, where I would like to access MS outlook, if it is installed on a client´s machine. The “access outlook” part has been done by referencing the outlook COM object, and going from there. My problem is now the “if it is installed” part. At the moment, my project doesn´t compile on machines without outlook installed, so I assume that I will have to not reference the outlook component, and instead load and use it dynamically, after detecting that outlook is present, but I haven´t found a way to do this. Am I correct, and does anybody have any hints on how to do this?

Thanks.

Edit: Resolved. Following the advice given by Hans Passant in one of the comments about using the office PIAs, proved to be the path of least resistance. I had a little difficulty getting the PIAs on my office-less machine, but it was overcome using the accepted answer to this question.

  • 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-20T14:03:09+00:00Added an answer on May 20, 2026 at 2:03 pm

    Following Hans Passant’s advice, I now answer my own question with details of my solution. I was able to both compile and run my project on a computer without office installed. The primary problem was to let visual studio know, which interface it could expect from the COM object. This was solved by finding a primary interface assembly (PIA) file for outlook. That process is better described in this question, but the short story is that I already had the office PIAs on my computer, in this location:

    C:\Program Files\Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA
    

    I use VS2010 pro, I don’t know if the files are included with other versions. It was then a matter of copying the relevant file to my project source folder, including it in my project and source control, and making a reference to it. After that, I was able to use Outlook COM types in my project and compile it without error. I am also able to run my project without office installed. This is achieved by trying to instantiate the relevant COM objects, and catching the exception if office is not installed. The following sample code shows how:

    using Outlook = Microsoft.Office.Interop.Outlook;
    
    namespace Foo
    {
        public class Bar
        {
            public void Quux()
            {
                try
                {
                    // try to instantiate outlook COM object.
                    Outlook.Application outlookApp = new Outlook.Application();
    
                    // if it works, fine. Proceed
                    ...
                }
                // If we catch a COMException, assume no office installed. Deal accordingly.
                catch (System.Runtime.InteropServices.COMException)
                {
                    ...
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a project (Web/PHP) where we would like users to access their files,
So in my project i would like have a nice treeview that has images.
I have an XNA project on WP7. I would like to get access to
I have a project that I would like to start beta testing soon, it
I have a project where I would like to generate a report export in
In my project I would like to have compile time checks on my existing
We have a PHP project that we would like to version control. Right now
i have a code generator project i would like to offer like open source,
I have a project written in C and I would like to know if
I have an MVC project that I would like to write in .NET 4.0

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.