System.Net.CredentialCache.Add Method

Adds a System.Net.NetworkCredential instance for use with SMTP to the credential cache and associates it with a host computer, port, and authentication protocol. Credentials added using this method are valid for SMTP only. This method does not work for HTTP or FTP requests.

Syntax

public void Add (string host, int port, string authenticationType, NetworkCredential credential)

Parameters

host
A string that identifies the host computer.
port
A int that specifies the port to connect to on host.
authenticationType
A string that identifies the authentication scheme used when connecting to host using cred. See Remarks.
credential
The System.Net.NetworkCredential to add to the credential cache.

Remarks

This method places a System.Net.NetworkCredential instance for use with SMTP into the System.Net.CredentialCache. The cache stores credentials in the order in which they are added to it. When the CredentialCache.GetCredential(string, int, string) method is called, it returns a System.Net.NetworkCredential instance that is selected by matching the host, port, and authType. The comparison is done case-insensitively.

The supported values for authType are "NTLM", "Digest", "Kerberos", and "Negotiate".

Credentials added with this method are only valid for use with SMTP. This method does not work for HTTP or FTP protocols.

Requirements

Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0