SmtpAccess Enum


指定允许的简单邮件传输协议 (SMTP) 服务器访问级别。Specifies the level of access allowed to a Simple Mail Transport Protocol (SMTP) server.

public enum class SmtpAccess
public enum SmtpAccess
type SmtpAccess = 
Public Enum SmtpAccess


Connect 1

连接到默认端口(端口 25)上的 SMTP 主机。Connection to an SMTP host on the default port (port 25).

ConnectToUnrestrictedPort 2

连接到任何端口上的 SMTP 主机。Connection to an SMTP host on any port.

None 0

不能访问 SMTP 主机。No access to an SMTP host.


下面的代码示例使用 SmtpAccess 枚举创建权限对象。The following code example uses the SmtpAccess enumeration to create a permission object.

static SmtpPermission^ CreateConnectPermission()
    SmtpPermission^ connectAccess = 
        gcnew SmtpPermission(SmtpAccess::Connect);
    Console::WriteLine("Access? {0}", connectAccess->Access);
    return connectAccess;
public static SmtpPermission CreateConnectPermission()
    SmtpPermission connectAccess = new
    Console.WriteLine("Access? {0}", connectAccess.Access);
    return connectAccess;


SmtpPermissionSmtpPermissionAttribute 类使用 SmtpAccess 枚举来指定对 SMTP 主机计算机的访问级别。The SmtpAccess enumeration is used by the SmtpPermission and SmtpPermissionAttribute classes to specify a level of access to an SMTP host computer. SmtpClient 类在将电子邮件发送到 SMTP 主机进行传递时要求 SmtpPermissionThe SmtpClient class demands an SmtpPermission when sending electronic mail to the SMTP host for delivery.

Applies to