Edit

Share via


SmtpAccess Enum

Definition

Specifies the level of access allowed to a Simple Mail Transport Protocol (SMTP) server.

C#
public enum SmtpAccess
Inheritance
SmtpAccess

Fields

Name Value Description
None 0

No access to an SMTP host.

Connect 1

Connection to an SMTP host on the default port (port 25).

ConnectToUnrestrictedPort 2

Connection to an SMTP host on any port.

Examples

The following code example uses the SmtpAccess enumeration to create a permission object.

C#
public static SmtpPermission CreateConnectPermission()
{
    SmtpPermission connectAccess = new
        SmtpPermission(SmtpAccess.Connect);
    Console.WriteLine("Access? {0}", connectAccess.Access);
    return connectAccess;
}

Remarks

The SmtpAccess enumeration is used by the SmtpPermission and SmtpPermissionAttribute classes to specify a level of access to an SMTP host computer. The SmtpClient class demands an SmtpPermission when sending electronic mail to the SMTP host for delivery.

Applies to

Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9