SmtpAccess Enumeration

SmtpAccess Enumeration


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

Namespace:   System.Net.Mail
Assembly:  System (in System.dll)

public enum SmtpAccess

Member nameDescription

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


Connection to an SMTP host on any port.


No access to an SMTP host.

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.

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

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

.NET Framework
Available since 2.0
Return to top
© 2015 Microsoft