SmtpClient.EnableSsl プロパティ
アセンブリ: System (system.dll 内)

Dim instance As SmtpClient Dim value As Boolean value = instance.EnableSsl instance.EnableSsl = value
/** @property */ public boolean get_EnableSsl () /** @property */ public void set_EnableSsl (boolean value)
SmtpClient が SSL を使用する場合は true。それ以外の場合は false。既定値は false です。

ClientCertificates を使用して、SSL 接続を確立するために使用する必要のあるクライアント証明書を指定できます。ServerCertificateValidationCallback を使用すると、SMTP サーバーによって指定された証明書を拒否できます。SecurityProtocol プロパティにより、使用する SSL プロトコルのバージョンを指定できます。

SMTP サーバーとの SSL 接続を確立し、その接続を使用して電子メールを送信するコード例を次に示します。
public static void CreateTestMessage(string server) { string to = "jane@contoso.com"; string from = "ben@contoso.com"; MailMessage message = new MailMessage(from, to); message.Subject = "Using the new SMTP client."; message.Body = @"Using this new feature, you can send an e-mail message from an application very easily."; SmtpClient client = new SmtpClient(server); // Credentials are necessary if the server requires the client // to authenticate before it will send e-mail on the client's behalf. client.UseDefaultCredentials = true; client.EnableSsl = true; client.Send(message); }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- SmtpClient.EnableSsl プロパティのページへのリンク