Rediger

Del via


SmtpException Constructors

Definition

Initializes a new instance of the SmtpException class.

Overloads

SmtpException()

Initializes a new instance of the SmtpException class.

SmtpException(SmtpStatusCode)

Initializes a new instance of the SmtpException class with the specified status code.

SmtpException(String)

Initializes a new instance of the SmtpException class with the specified error message.

SmtpException(SmtpStatusCode, String)

Initializes a new instance of the SmtpException class with the specified status code and error message.

SmtpException(SerializationInfo, StreamingContext)
Obsolete.

Initializes a new instance of the SmtpException class from the specified instances of the SerializationInfo and StreamingContext classes.

SmtpException(String, Exception)

Initializes a new instance of the SmtpException class with the specified error message and inner exception.

SmtpException()

Source:
SmtpException.cs
Source:
SmtpException.cs
Source:
SmtpException.cs

Initializes a new instance of the SmtpException class.

public:
 SmtpException();
public SmtpException ();
Public Sub New ()

Examples

The following code example demonstrates calling this constructor.

static SmtpException^ GenerateDefaultSmtpException()
{
   return gcnew SmtpException;
}
public static SmtpException GenerateDefaultSmtpException()
{
    return new SmtpException();
}

Remarks

The exception returned by this constructor has its StatusCode property set to GeneralFailure.

Applies to

SmtpException(SmtpStatusCode)

Source:
SmtpException.cs
Source:
SmtpException.cs
Source:
SmtpException.cs

Initializes a new instance of the SmtpException class with the specified status code.

public:
 SmtpException(System::Net::Mail::SmtpStatusCode statusCode);
public SmtpException (System.Net.Mail.SmtpStatusCode statusCode);
new System.Net.Mail.SmtpException : System.Net.Mail.SmtpStatusCode -> System.Net.Mail.SmtpException
Public Sub New (statusCode As SmtpStatusCode)

Parameters

statusCode
SmtpStatusCode

An SmtpStatusCode value.

Examples

The following code example demonstrates calling this constructor.

static SmtpException^ GenerateSmtpException( SmtpStatusCode status )
{
   return gcnew SmtpException( status );
}
public static SmtpException GenerateSmtpException(SmtpStatusCode status)
{
    return new SmtpException(status);
}

Remarks

This constructor uses the statusCode parameter to initialize the StatusCode property.

Applies to

SmtpException(String)

Source:
SmtpException.cs
Source:
SmtpException.cs
Source:
SmtpException.cs

Initializes a new instance of the SmtpException class with the specified error message.

public:
 SmtpException(System::String ^ message);
public SmtpException (string? message);
public SmtpException (string message);
new System.Net.Mail.SmtpException : string -> System.Net.Mail.SmtpException
Public Sub New (message As String)

Parameters

message
String

A String that describes the error that occurred.

Examples

The following code example demonstrates calling this constructor.

static SmtpException^ GenerateSmtpException( String^ message )
{
   return gcnew SmtpException( message );
}
public static SmtpException GenerateSmtpException(string message)
{
    return new SmtpException(message);
}

Remarks

This constructor uses the message parameter to initialize the Message property.

Applies to

SmtpException(SmtpStatusCode, String)

Source:
SmtpException.cs
Source:
SmtpException.cs
Source:
SmtpException.cs

Initializes a new instance of the SmtpException class with the specified status code and error message.

public:
 SmtpException(System::Net::Mail::SmtpStatusCode statusCode, System::String ^ message);
public SmtpException (System.Net.Mail.SmtpStatusCode statusCode, string? message);
public SmtpException (System.Net.Mail.SmtpStatusCode statusCode, string message);
new System.Net.Mail.SmtpException : System.Net.Mail.SmtpStatusCode * string -> System.Net.Mail.SmtpException
Public Sub New (statusCode As SmtpStatusCode, message As String)

Parameters

statusCode
SmtpStatusCode

An SmtpStatusCode value.

message
String

A String that describes the error that occurred.

Examples

The following code example demonstrates calling this constructor.

static SmtpException^ GenerateSmtpException( SmtpStatusCode status, String^ message )
{
   return gcnew SmtpException( status,message );
}
public static SmtpException GenerateSmtpException(SmtpStatusCode status, string message)
{
    return new SmtpException(status, message);
}

Remarks

This constructor uses the statusCode parameter to initialize the StatusCode property and uses the message parameter to initialize the Message property.

Applies to

SmtpException(SerializationInfo, StreamingContext)

Source:
SmtpException.cs
Source:
SmtpException.cs
Source:
SmtpException.cs

Caution

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

Initializes a new instance of the SmtpException class from the specified instances of the SerializationInfo and StreamingContext classes.

protected:
 SmtpException(System::Runtime::Serialization::SerializationInfo ^ serializationInfo, System::Runtime::Serialization::StreamingContext streamingContext);
protected SmtpException (System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected SmtpException (System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext);
new System.Net.Mail.SmtpException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Net.Mail.SmtpException
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Net.Mail.SmtpException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Net.Mail.SmtpException
Protected Sub New (serializationInfo As SerializationInfo, streamingContext As StreamingContext)

Parameters

serializationInfo
SerializationInfo

A SerializationInfo that contains the information required to serialize the new SmtpException.

streamingContext
StreamingContext

A StreamingContext that contains the source and destination of the serialized stream associated with the new instance.

Attributes

Remarks

This constructor implements the ISerializable interface for the SmtpException class.

Applies to

SmtpException(String, Exception)

Source:
SmtpException.cs
Source:
SmtpException.cs
Source:
SmtpException.cs

Initializes a new instance of the SmtpException class with the specified error message and inner exception.

public:
 SmtpException(System::String ^ message, Exception ^ innerException);
public SmtpException (string? message, Exception? innerException);
public SmtpException (string message, Exception innerException);
new System.Net.Mail.SmtpException : string * Exception -> System.Net.Mail.SmtpException
Public Sub New (message As String, innerException As Exception)

Parameters

message
String

A String that describes the error that occurred.

innerException
Exception

The exception that is the cause of the current exception.

Examples

The following code example demonstrates calling this constructor.

static SmtpException^ GenerateSmtpException( String^ message, Exception^ innerException )
{
   return gcnew SmtpException( message,innerException );
}
public static SmtpException GenerateSmtpException(string message, Exception innerException)
{
    return new SmtpException(message, innerException);
}

Remarks

This constructor uses the message parameter to initialize the Message property and the innerException parameter to initialize the InnerException property.

If innerException is not null, the current exception is raised in a catch block that handles innerException.

Applies to