クリックして評価とフィードバックをお寄せください
MSDN
MSDN ライブラリ
.NET 開発
.NET Framework 3.5
.NET Framework 3.5
System.Net.Mail 名前空間
SmtpClient クラス
SmtpClient プロパティ
 EnableSsl プロパティ

  低帯域幅での表示をオンにする
このページは次のバージョンについて記述しています。
Microsoft Visual Studio 2008/.NET Framework 3.5

その他のバージョンについては、以下の情報を参照してください。
.NET Framework クラス ライブラリ
SmtpClient..::.EnableSsl プロパティ

更新 : 2007 年 11 月

SmtpClient が、接続を暗号化するために SSL (Secure Sockets Layer) を使用するかどうかを指定します。

名前空間 :  System.Net.Mail
アセンブリ :  System (System.dll 内)

Visual Basic (宣言)
Public Property EnableSsl As Boolean
Visual Basic (使用法)
Dim instance As SmtpClient
Dim value As Boolean

value = instance.EnableSsl

instance.EnableSsl = value
C#
public bool EnableSsl { get; set; }
Visual C++
public:
property bool EnableSsl {
    bool get ();
    void set (bool value);
}
J#
/** @property */
public boolean get_EnableSsl()
/** @property */
public  void set_EnableSsl(boolean value)
JScript
public function get EnableSsl () : boolean
public function set EnableSsl (value : boolean)

プロパティ値

型 : System..::.Boolean

SmtpClient が SSL を使用する場合は true。それ以外の場合は false。既定値は false です。

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

SMTP サーバーとの SSL 接続を確立し、その接続を使用して電子メールを送信するコード例を次に示します。

C#
        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 Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。

.NET Framework

サポート対象 : 3.5、3.0、2.0
コミュニティ コンテンツ   コミュニティ コンテンツとは
新しいコンテンツの追加 RSS  注釈
Processing
© 2009 Microsoft Corporation. All rights reserved. 使用条件  |  商標  |  プライバシー
Page view tracker