Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect/Determine Default Email Pgm/Application on Windows 7

Status
Not open for further replies.

Statey603

Programmer
Nov 10, 2009
196
US
Hi,

Trying to determine what Email Program is configured in Windows 7 as the Default Email Program.
Have tried checking the Registry Keys but having very inconsistent results.
The inconsistency is not with the PB code, it's with the registry Keys.
RegistryGet("HKEY_CURRENT_USER\Software\Clients\mail",',RegString!, ls_email)
* Tried this code for each of the keys listed below.
Code works fine to get the key value, problem is the key is not always there - see HKEY_CURRENT_USERS.

On one Win 7 PC, Lotus Notes and Outlook both have been installed.
User A has MS Outlook set as Default Email Program.
User B has Lotus Notes set as Default Email Program.

PC #1 [2 user accounts, each has different default email pgm]
Registry: [NOTE: Registry Keys viewed while signed in as user B]
HKEY_CLASSES_ROOT\mailto\shell\open\command: [Microsoft Outlook]
I also checked the following:
HKEY_LOCAL_MACHINE\Software\Clients\mail: [Microsoft Outlook]
* I don't think these are right. User B has Lotus Notes set as Default Email Pgm and never opened Outlook, but the fact is these might not be user specific. Decided to look at USER keys.
HKEY_CURRENT_USER\Software\Clients\mail: [Lotus Notes]
* This was encouraging.

However, on the other machine which only has had Lotus Notes installed/configured, there isn't even a Clients section under HKEY_CURRENT_USER\Software\ so I guess I can't use that key.
PC #2 [one user account, one email pgm]
Registry:
HKEY_LOCAL_MACHINE\Software\Clients\mail: [Lotus Notes]
HKEY_CURRENT_USER\Software\Clients\mail:
* Key Does not exist. Clients section doesn't exist either.

- See attached screen shot of registry

I appreciate any recommendations or findings on a consistent way/key to determine the Default Email Program based on the current logged in User on windows 7.

Thanks.
 
I figured out a workaround for this in case anybody else runs into this inconsistency with the registry concerning the Default Email Client.

Background:
Registry Key HKCR\mailto\shell\open\command does not return consistent results. On a PC where both Outlook and Lotus Notes were installed, it indicated Outlook even when Lotus Notes was set as the Default. Discovered that in this case, HKCU\Software\Clients\mail contained the correct 'Lotus Notes' value.
However, it was also discovered that this key is also not reliable [by itself]. On another PC, with only Lotus Notes configured, this key did not exist. The [HKCR mailto command] key did, however, contain the correct value [Lotus Notes] in this case.

Pseudo-Code
Decided to use a 2 tiered approach to the registry check.

IF HKCR\mailto\shell\open\command is 'Outlook' THEN
check HKCU\Software\Clients\mail
and use its value as the Default Email Client.
ELSE If HKCR\mailto\shell\open\command is 'Lotus Notes' THEN
no need to go further
Use Lotus Notes Email Client
END ID


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top