/// <summary> /// Launches the default mail client. /// </summary> public void LaunchDefaultMailClient() { // Open the "HKLM\SOFTWARE\Clients\Mail" key. Microsoft.Win32.RegistryKey mailKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey( @"SOFTWARE\Clients\Mail" ); // The default mail application is stored in the default value of that key. string defaultMailApp = (string)mailKey.GetValue( null ); if( defaultMailApp != null && defaultMailApp.Length > 0 ) { // Open the subkey of the default mail application and the "shell\open\command" key below that. Microsoft.Win32.RegistryKey cmdKey = mailKey.OpenSubKey( defaultMailApp + @"\shell\open\command" ); // We're now in "HKLM\SOFTWARE\Clients\Mail\<default-mail-app>\shell\open\command". // The default value of this key is the command line to start. string command = (string)cmdKey.GetValue( null ); // If there are command arguments, extract them out of the main command string. string args = string.Empty; if( command.IndexOf( " " ) > 0 ) { args = command.Substring( command.IndexOf( " " ) + 1 ); command = command.Substring( 0, command.IndexOf( " " ) ); } // Start a new process for the mail application. System.Diagnostics.Process.Start( command, args ); } }
看了,用了。不成功。我们企业内部地址是 [email protected]
那位大哥帮忙给个例子。
可不可以用outlook 设置好定时发邮件呢?
然后用.net 来定时调用它?
/// Launches the default mail client.
/// </summary>
public void LaunchDefaultMailClient()
{
// Open the "HKLM\SOFTWARE\Clients\Mail" key.
Microsoft.Win32.RegistryKey mailKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey( @"SOFTWARE\Clients\Mail" ); // The default mail application is stored in the default value of that key.
string defaultMailApp = (string)mailKey.GetValue( null ); if( defaultMailApp != null && defaultMailApp.Length > 0 )
{
// Open the subkey of the default mail application and the "shell\open\command" key below that.
Microsoft.Win32.RegistryKey cmdKey = mailKey.OpenSubKey( defaultMailApp + @"\shell\open\command" ); // We're now in "HKLM\SOFTWARE\Clients\Mail\<default-mail-app>\shell\open\command".
// The default value of this key is the command line to start.
string command = (string)cmdKey.GetValue( null ); // If there are command arguments, extract them out of the main command string.
string args = string.Empty;
if( command.IndexOf( " " ) > 0 )
{
args = command.Substring( command.IndexOf( " " ) + 1 );
command = command.Substring( 0, command.IndexOf( " " ) );
} // Start a new process for the mail application.
System.Diagnostics.Process.Start( command, args );
}
}
tempClient.Host = "202.108.5.141"; //邮件服务器ip地址仁兄的博客
建邮件服务器