SmtpClient.Port Property
.NET Framework (current version)
Gets or sets the port used for SMTP transactions.
Assembly: System (in System.dll)
| Exception | Condition |
|---|---|
| ArgumentOutOfRangeException | The value specified for a set operation is less than or equal to zero. |
| InvalidOperationException | You cannot change the value of this property when an email is being sent. |
The value of the Port property can also be set using constructors or the application or machine configuration file. For more information about using configuration files, see <mailSettings> Element (Network Settings). If information is specified using this property, this information overrides the configuration file settings.
SmtpPermission
to set the Port property. Associated enumeration: SmtpAccess.ConnectToUnrestrictedPort.
.NET Framework
Available since 2.0
Available since 2.0
Show: