共用方式為


SmtpClient.ClientCertificates 屬性

定義

指定應該用來建立 Secure Sockets Layer (SSL) 連線的憑證。

public:
 property System::Security::Cryptography::X509Certificates::X509CertificateCollection ^ ClientCertificates { System::Security::Cryptography::X509Certificates::X509CertificateCollection ^ get(); };
public System.Security.Cryptography.X509Certificates.X509CertificateCollection ClientCertificates { get; }
member this.ClientCertificates : System.Security.Cryptography.X509Certificates.X509CertificateCollection
Public ReadOnly Property ClientCertificates As X509CertificateCollection

屬性值

X509CertificateCollection,保存一個或多個用戶端憑證。 預設值是擷取自組態檔中的郵件組態屬性 (Attribute)。

範例

下列程式代碼範例會建立與 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 email 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 email on the client's behalf.
    client.UseDefaultCredentials = true;
                client.EnableSsl = true;
    client.Send(message);
}

備註

用戶端憑證預設為選擇性;不過,伺服器組態可能需要用戶端在初始連線交涉中呈現有效的憑證。

注意

架構會在建立 SSL 工作階段時快取 SSL 工作階段,並盡可能嘗試重複使用新要求的快取會話。 嘗試重複使用 SSL 會話時,Framework 會在有一個) 時使用 (的第 ClientCertificates 一個專案,或嘗試在空白的情況下 ClientCertificates 重複使用匿名會話。

適用於

另請參閱