SmtpException SmtpException SmtpException SmtpException Constructors

Definition

Overloads

SmtpException() SmtpException() SmtpException()

Initializes a new instance of the SmtpException class.

SmtpException(SmtpStatusCode) SmtpException(SmtpStatusCode) SmtpException(SmtpStatusCode) SmtpException(SmtpStatusCode)

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

SmtpException(String) SmtpException(String) SmtpException(String) SmtpException(String)

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

SmtpException(SmtpStatusCode, String) SmtpException(SmtpStatusCode, String) SmtpException(SmtpStatusCode, String) SmtpException(SmtpStatusCode, String)

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

SmtpException(String, Exception) SmtpException(String, Exception) SmtpException(String, Exception) SmtpException(String, Exception)

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

SmtpException(SerializationInfo, StreamingContext) SmtpException(SerializationInfo, StreamingContext) SmtpException(SerializationInfo, StreamingContext) SmtpException(SerializationInfo, StreamingContext)

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

SmtpException() SmtpException() SmtpException()

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.

SmtpException(SmtpStatusCode) SmtpException(SmtpStatusCode) SmtpException(SmtpStatusCode) SmtpException(SmtpStatusCode)

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

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.

SmtpException(String) SmtpException(String) SmtpException(String) SmtpException(String)

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

public:
 SmtpException(System::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 String String 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.

SmtpException(SmtpStatusCode, String) SmtpException(SmtpStatusCode, String) SmtpException(SmtpStatusCode, String) SmtpException(SmtpStatusCode, String)

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);
new System.Net.Mail.SmtpException : System.Net.Mail.SmtpStatusCode * string -> System.Net.Mail.SmtpException
Public Sub New (statusCode As SmtpStatusCode, message As String)

Parameters

message
String String String 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.

SmtpException(String, Exception) SmtpException(String, Exception) SmtpException(String, Exception) SmtpException(String, Exception)

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);
new System.Net.Mail.SmtpException : string * Exception -> System.Net.Mail.SmtpException
Public Sub New (message As String, innerException As Exception)

Parameters

message
String String String String

A String that describes the error that occurred.

innerException
Exception Exception Exception 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.

SmtpException(SerializationInfo, StreamingContext) SmtpException(SerializationInfo, StreamingContext) SmtpException(SerializationInfo, StreamingContext) SmtpException(SerializationInfo, StreamingContext)

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

protected:
 SmtpException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected SmtpException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Net.Mail.SmtpException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Net.Mail.SmtpException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Parameters

serializationInfo
SerializationInfo SerializationInfo SerializationInfo SerializationInfo

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

streamingContext
StreamingContext StreamingContext StreamingContext StreamingContext

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

Remarks

This constructor implements the ISerializable interface for the SmtpException class.

Applies to