How do I set standard email client in Windows 7 using .NET

青春壹個敷衍的年華 提交于 2019-12-11 05:37:13

问题


I would like to set the standard email client in Windows 7 from .NET code, how do I do it?


回答1:


You would need to edit the following registry value. You would do something like the following with the Registry.SetValue Method.

Registry.SetValue(@"HKEY_CLASSES_ROOT\mailto\shell\open\command", "", "\"C:\\PROGRA~2\\MICROS~1\\Office14\\OUTLOOK.EXE\" -c IPM.Note /m \"%1\"");

Reference:
http://msdn.microsoft.com/en-us/library/3dwk5axy.aspx


回答2:


You can find the default email program with the following Registry Key. Find it's content and mess with it:

Check the following link here at SO:

Find default email client

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());
      }
   }
}


来源:https://stackoverflow.com/questions/16359113/how-do-i-set-standard-email-client-in-windows-7-using-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!