SmtpPermission Constructors
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the SmtpPermission class.
Overloads
SmtpPermission(Boolean) |
Initializes a new instance of the SmtpPermission class with the specified state. |
SmtpPermission(SmtpAccess) |
Initializes a new instance of the SmtpPermission class using the specified access level. |
SmtpPermission(PermissionState) |
Initializes a new instance of the SmtpPermission class using the specified permission state value. |
SmtpPermission(Boolean)
- Source:
- SmtpPermission.cs
- Source:
- SmtpPermission.cs
- Source:
- SmtpPermission.cs
- Source:
- SmtpPermission.cs
Initializes a new instance of the SmtpPermission class with the specified state.
public:
SmtpPermission(bool unrestricted);
public SmtpPermission (bool unrestricted);
new System.Net.Mail.SmtpPermission : bool -> System.Net.Mail.SmtpPermission
Public Sub New (unrestricted As Boolean)
Parameters
- unrestricted
- Boolean
true
if the new permission is unrestricted; otherwise, false
.
Examples
The following code example demonstrates calling this constructor.
static SmtpPermission^ CreateUnrestrictedPermission2()
{
SmtpPermission^ allAccess = gcnew SmtpPermission(true);
Console::WriteLine("Is unrestricted? {0}",
allAccess->IsUnrestricted());
return allAccess;
}
public static SmtpPermission CreateUnrestrictedPermission2()
{
SmtpPermission allAccess = new
SmtpPermission(true);
Console.WriteLine("Is unrestricted? {0}",
allAccess.IsUnrestricted());
return allAccess;
}
Remarks
If unrestricted
is true
, the permission controls Connect access to SMTP servers. If unrestricted is false
, the permission controls None access.
Applies to
SmtpPermission(SmtpAccess)
- Source:
- SmtpPermission.cs
- Source:
- SmtpPermission.cs
- Source:
- SmtpPermission.cs
- Source:
- SmtpPermission.cs
Initializes a new instance of the SmtpPermission class using the specified access level.
public:
SmtpPermission(System::Net::Mail::SmtpAccess access);
public SmtpPermission (System.Net.Mail.SmtpAccess access);
new System.Net.Mail.SmtpPermission : System.Net.Mail.SmtpAccess -> System.Net.Mail.SmtpPermission
Public Sub New (access As SmtpAccess)
Parameters
- access
- SmtpAccess
One of the SmtpAccess values.
Examples
The following code example demonstrates calling this constructor.
static SmtpPermission^ CreateConnectPermission()
{
SmtpPermission^ connectAccess =
gcnew SmtpPermission(SmtpAccess::Connect);
Console::WriteLine("Access? {0}", connectAccess->Access);
return connectAccess;
}
public static SmtpPermission CreateConnectPermission()
{
SmtpPermission connectAccess = new
SmtpPermission(SmtpAccess.Connect);
Console.WriteLine("Access? {0}", connectAccess.Access);
return connectAccess;
}
Remarks
The permission created by this constructor can be used to help secure access to SMTP servers.
Applies to
SmtpPermission(PermissionState)
- Source:
- SmtpPermission.cs
- Source:
- SmtpPermission.cs
- Source:
- SmtpPermission.cs
- Source:
- SmtpPermission.cs
Initializes a new instance of the SmtpPermission class using the specified permission state value.
public:
SmtpPermission(System::Security::Permissions::PermissionState state);
public SmtpPermission (System.Security.Permissions.PermissionState state);
new System.Net.Mail.SmtpPermission : System.Security.Permissions.PermissionState -> System.Net.Mail.SmtpPermission
Public Sub New (state As PermissionState)
Parameters
- state
- PermissionState
One of the PermissionState values.
Examples
The following code example demonstrates calling this constructor.
static SmtpPermission^ CreateUnrestrictedPermission()
{
SmtpPermission^ allAccess =
gcnew SmtpPermission(PermissionState::Unrestricted);
Console::WriteLine("Is unrestricted? {0}",
allAccess->IsUnrestricted());
return allAccess;
}
public static SmtpPermission CreateUnrestrictedPermission()
{
SmtpPermission allAccess = new
SmtpPermission(System.Security.Permissions.PermissionState.Unrestricted);
Console.WriteLine("Is unrestricted? {0}",
allAccess.IsUnrestricted());
return allAccess;
}
Remarks
The permission created by this constructor can be used to give full access or prevent all access to SMTP servers.
Applies to
.NET