Find default email client

Using C #, how can I determine which program is registered as my default email client? I do not need to run the application, I just want to know what it is.

+6
c # email email-client
source share
5 answers

Use the registry class to search the registry. This console application demonstrates the principle.

using System; using Microsoft.Win32; namespace RegistryTestApp { class Program { static void Main(string[] args) { object mailClient = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail", "", "none"); Console.WriteLine(mailClient.ToString()); } } } 
+9
source share

You can look in the registry for the following key:

 HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail 
+8
source share

You can read this registry key from

 HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail 
+3
source share

The default email client is user dependent. HKLM lists all registered email clients; the first one returned may not be the current default user. Better to read HKEY_CURRENT_USER\Software\Clients\Mail .

It also gives you the name of the email application. If you want its executable name, you need to continue with something like:

 object mailCommand = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\" + mailClient.ToString() + @"\shell\open\command", "", "none"); 

and then remove anything extraneous from the command line you don’t need (quotation marks, options).

+3
source share

I think you can find this information in the registry by HKLM\Software\Clients\Mail .

Find the default string value.

+1
source share

All Articles