How to detect whether Outlook is configured on machine using Regis

M

makarand devalekar

Hi,

I need to perform following two checks before using Outlook object model.
1. whether Outlook is installed on a machine
2. If installed whether it is configured or not for current user

I need to check these from registry entries before instantiating Outlook
Object through C#.

I tried following check from registry entry,
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows
Messaging Subsystem\Profiles

Currently I look for any entry inside this i.e. "Profiles" folder . If
there is not any folder inside this folder I assume that the Outlook is
not configured for the current user. However, this check does not work some
or other time.

Any pointers in this will really be helpful.

Thanking in advance

~Makarand
 
K

Ken Slovak - [MVP - Outlook]

To see if Outlook is installed you can look for
HKCR\Outlook.Application\CLSID and see if it has a value of
"{0006F03A-0000-0000-C000-000000000046}". That's in the (Default) value for
that key. The (Default) value for HKCR\Outlook.Application tells you which
version such as "Microsoft Outlook 11.0 Object Library".

What doesn't work with your check on \Profiles?
 
M

makarand devalekar

Thanks Ken for prompt reply.

As I mentioned previously I keep checking following registry entry to know
whether Outlook is configured or not for the current user,
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows
Messaging Subsystem\Profiles

Here, I assume that the Outlook is not configured for the current user if
there are no folders created inside \Profiles folder.
This check works fine for fresh machine with no Outlook profiles configured
on it .
However, this check fails during round trip i.e. first configure profile
for the current user and then remove profile for the current user.
This happens because I get some folders entries created inside \Profiles
folder.
In some cases the folder which was created inside \Profiles folder during
configuration of user profile is not getting removed even though I remove
profile for the user.

Let me know if there is any registry entry which can tell me whether Outlook
is configured for the current user.
Please find the code below for more details:
Here,
using ol = Microsoft.Office.Interop.Outlook;

/// <summary>
/// Checks whether Outlook is configured or not for current user
/// </summary>
/// <returns>true if Outlook is configured else false</returns>
private static bool IsOutlookProfileConfigured()
{
try
{
///Note - following code checks two scenarios to decide
whether Outlook is configured on a machine for current user.
///Scenario I
///Here Machine is a fresh machine having no Outlook
profiles added to it.
///
ol.Application OlApplication = new ol.Application();
RegistryKey currentUser = Registry.CurrentUser;
RegistryKey regWMSprofile = currentUser.OpenSubKey
(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows
Messaging Subsystem\Profiles");
if (regWMSprofile == null)
{
return false;
}
else
{
/// Scenario II
/// Here, Outlook profiles are added for current user
but check whether Outlook application
/// contains Email accounts using Outlook Object Model

if (regWMSprofile.SubKeyCount > 0)
{
if (OlApplication == null)
{
return false;
}
ol.NameSpace olNameSpace =
OlApplication.GetNamespace("MAPI");

/// Note: This check is required bcoz eventhough
Outlook is installed and configured
///on machines sometimes it can have no email
Accounts added to it.

if (olNameSpace != null && olNameSpace.Accounts !=
null && olNameSpace.Accounts.Count > 0)
{
return true;
}
}
else
{
return false;
}
}
}
catch (Exception ex)
{
return false;
}

return false;
}

Thanks again.


~Makarand


Ken Slovak - said:
To see if Outlook is installed you can look for
HKCR\Outlook.Application\CLSID and see if it has a value of
"{0006F03A-0000-0000-C000-000000000046}". That's in the (Default) value for
that key. The (Default) value for HKCR\Outlook.Application tells you which
version such as "Microsoft Outlook 11.0 Object Library".

What doesn't work with your check on \Profiles?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


makarand devalekar said:
Hi,

I need to perform following two checks before using Outlook object model.
1. whether Outlook is installed on a machine
2. If installed whether it is configured or not for current user

I need to check these from registry entries before instantiating Outlook
Object through C#.

I tried following check from registry entry,
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows
Messaging Subsystem\Profiles

Currently I look for any entry inside this i.e. "Profiles" folder . If
there is not any folder inside this folder I assume that the Outlook is
not configured for the current user. However, this check does not work
some
or other time.

Any pointers in this will really be helpful.

Thanking in advance

~Makarand
 
K

Ken Slovak - [MVP - Outlook]

If pieces of the profile settings remain after the profile is deleted then
I'm not sure what you can do other than use Extended MAPI the ProfMan
utility library that comes with Redemption (www.dimastr.com/redemption).

Either of those would let you enumerate profiles, but Extended MAPI can only
be programmed using C++ or Delphi.
 

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