.NET Framework Class Library SmtpStatusCode Enumeration Specifies the outcome of sending e-mail by using the SmtpClient class.
Namespace:
System.Net.Mail
Assembly:
System (in System.dll)

Syntax
Public Enumeration SmtpStatusCode
public enum SmtpStatusCode
public enum class SmtpStatusCode

Members
| Member name | Description |
|---|
| SystemStatus | A system status or system Help reply. | | HelpMessage | A Help message was returned by the service. | | ServiceReady | The SMTP service is ready. | | ServiceClosingTransmissionChannel | The SMTP service is closing the transmission channel. | | Ok | The email was successfully sent to the SMTP service. | | UserNotLocalWillForward | The user mailbox is not located on the receiving server; the server forwards the e-mail. | | CannotVerifyUserWillAttemptDelivery | The specified user is not local, but the receiving SMTP service accepted the message and attempted to deliver it. This status code is defined in RFC 1123, which is available at http://www.ietf.org. | | StartMailInput | The SMTP service is ready to receive the e-mail content. | | ServiceNotAvailable | The SMTP service is not available; the server is closing the transmission channel. | | MailboxBusy | The destination mailbox is in use. | | LocalErrorInProcessing | The SMTP service cannot complete the request. This error can occur if the client's IP address cannot be resolved (that is, a reverse lookup failed). You can also receive this error if the client domain has been identified as an open relay or source for unsolicited e-mail (spam). For details, see RFC 2505, which is available at http://www.ietf.org. | | InsufficientStorage | The SMTP service does not have sufficient storage to complete the request. | | ClientNotPermitted | The client was not authenticated or is not allowed to send mail using the specified SMTP host. | | CommandUnrecognized | The SMTP service does not recognize the specified command. | | SyntaxError | The syntax used to specify a command or parameter is incorrect. | | CommandNotImplemented | The SMTP service does not implement the specified command. | | BadCommandSequence | The commands were sent in the incorrect sequence. | | MustIssueStartTlsFirst | The SMTP server is configured to accept only TLS connections, and the SMTP client is attempting to connect by using a non-TLS connection. The solution is for the user to set EnableSsl=true on the SMTP Client. | | CommandParameterNotImplemented | The SMTP service does not implement the specified command parameter. | | MailboxUnavailable | The destination mailbox was not found or could not be accessed. | | UserNotLocalTryAlternatePath | The user mailbox is not located on the receiving server. You should resend using the supplied address information. | | ExceededStorageAllocation | The message is too large to be stored in the destination mailbox. | | MailboxNameNotAllowed | The syntax used to specify the destination mailbox is incorrect. | | TransactionFailed | The transaction failed. | | GeneralFailure | The transaction could not occur. You receive this error when the specified SMTP host cannot be found. |

Remarks

Examples
The following code example displays an error message to the console when an SmtpException is thrown.
public static void CreateMessageWithAttachment3(string server, string to)
{
// Specify the file to be attached and sent.
// This example assumes that a file named Data.xls exists in the
// current working directory.
string file = "data.xls";
// Create a message and set up the recipients.
MailMessage message = new MailMessage(
"ReportMailer@contoso.com",
to,
"Quarterly data report",
"See the attached spreadsheet.");
// Create the file attachment for this e-mail message.
Attachment data = new Attachment("Qtr3.xls");
// Add time stamp information for the file.
ContentDisposition disposition = data.ContentDisposition;
disposition.CreationDate = System.IO.File.GetCreationTime(file);
disposition.ModificationDate = System.IO.File.GetLastWriteTime(file);
disposition.ReadDate = System.IO.File.GetLastAccessTime(file);
// Add the file attachment to this e-mail message.
message.Attachments.Add(data);
//Send the message.
SmtpClient client = new SmtpClient(server);
// Add credentials if the SMTP server requires them.
client.Credentials = (ICredentialsByHost)CredentialCache.DefaultNetworkCredentials;
// Notify user if an error occurs.
try
{
client.Send(message);
}
catch (SmtpException e)
{
Console.WriteLine("Error: {0}", e.StatusCode);
}
finally
{
data.Dispose();
}
}
static void CreateMessageWithAttachment3( String^ server, String^ to )
{
// Specify the file to be attached and sent.
// This example assumes that a file named data.xls exists in the
// current working directory.
String^ file = L"data.xls";
// Create a message and set up the recipients.
MailMessage^ message = gcnew MailMessage( L"ReportMailer@contoso.com",to,L"Quarterly data report",L"See the attached spreadsheet." );
// Create the file attachment for this e-mail message.
Attachment^ data = gcnew Attachment("Qtr3.xls");
// Add time stamp information for the file.
ContentDisposition^ disposition = data->ContentDisposition;
disposition->CreationDate = System::IO::File::GetCreationTime( file );
disposition->ModificationDate = System::IO::File::GetLastWriteTime( file );
disposition->ReadDate = System::IO::File::GetLastAccessTime( file );
// Add the file attachment to this e-mail message.
message->Attachments->Add( data );
//Send the message.
SmtpClient^ client = gcnew SmtpClient( server );
// Add credentials if the SMTP server requires them.
client->Credentials = dynamic_cast<ICredentialsByHost^>(CredentialCache::DefaultNetworkCredentials);
// Notify user if an error occurs.
try
{
client->Send( message );
}
catch ( SmtpException^ e )
{
Console::WriteLine( L"Error: {0}", e->StatusCode );
}
finally
{
data->~Attachment();
client->~SmtpClient();
}
}

Version Information
.NET FrameworkSupported in: 4, 3.5, 3.0, 2.0 .NET Framework Client ProfileSupported in: 4, 3.5 SP1

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

See Also
|
Biblioteca de clases de .NET Framework SmtpStatusCode (Enumeración) Especifica el resultado de enviar correo electrónico utilizando la clase SmtpClient.
Espacio de nombres:
System.Net.Mail
Ensamblado:
System (en System.dll)

Sintaxis
Public Enumeration SmtpStatusCode
public enum SmtpStatusCode
public enum class SmtpStatusCode

Miembros
| Nombre de miembro | Descripción |
|---|
| SystemStatus | Estado del sistema o respuesta de ayuda del sistema. | | HelpMessage | El servicio devolvió un mensaje de ayuda. | | ServiceReady | El servicio SMTP está listo. | | ServiceClosingTransmissionChannel | El servicio SMTP está cerrando el canal de transmisión. | | Ok | El mensaje de correo electrónico se ha enviado correctamente al servicio SMTP. | | UserNotLocalWillForward | No se ha encontrado el buzón del usuario en el servidor receptor; el servidor reenvía el correo electrónico. | | CannotVerifyUserWillAttemptDelivery | El usuario especificado no es local, pero el servicio SMTP receptor aceptó el mensaje e intentó entregarlo. Este código de estado se define en el documento RFC 1123, que está disponible en http://www.ietf.org. | | StartMailInput | El servicio SMTP está listo para recibir el contenido del correo electrónico. | | ServiceNotAvailable | El servicio SMTP no está disponible; el servidor está cerrando el canal de transmisión. | | MailboxBusy | El buzón de destino se está utilizando en estos momentos. | | LocalErrorInProcessing | El servicio SMTP no puede completar la solicitud. Este error puede producirse si la dirección IP del cliente no puede resolverse (es decir, si una búsqueda inversa produjo un error). También puede recibir este error si el dominio del cliente se ha identificado como una retransmisión abierta u origen para el correo electrónico no solicitado (spam). Para obtener información detallada, vea el documento RFC 2505, que está disponible en http://www.ietf.org. | | InsufficientStorage | El servicio SMTP no dispone de suficiente espacio de almacenamiento como para completar la solicitud. | | ClientNotPermitted | No se ha autenticado el cliente o no tiene permiso para enviar correo utilizando el host SMTP especificado. | | CommandUnrecognized | El servicio SMTP no reconoce el comando especificado. | | SyntaxError | La sintaxis utilizada para especificar un comando o parámetro es incorrecta. | | CommandNotImplemented | El servicio SMTP no implementa el comando especificado. | | BadCommandSequence | Los comandos se enviaron en la secuencia incorrecta. | | MustIssueStartTlsFirst | El servidor SMTP está configurado para aceptar únicamente conexiones TLS y el cliente SMTP está intentando conectarse utilizando una conexión que no es TLS. Para solucionarlo, el usuario deberá establecer EnableSsl=true en el cliente SMTP. | | CommandParameterNotImplemented | El servicio SMTP no implementa el parámetro de comando especificado. | | MailboxUnavailable | No se ha encontrado el buzón de destino o no se ha podido obtener acceso al mismo. | | UserNotLocalTryAlternatePath | No se ha encontrado el buzón del usuario en el servidor receptor. Debería reenviar el correo utilizando la información de dirección suministrada. | | ExceededStorageAllocation | El mensaje es demasiado grande para almacenarse en el buzón de destino. | | MailboxNameNotAllowed | La sintaxis utilizada para especificar el buzón de destino es incorrecta. | | TransactionFailed | Se ha producido un error en la transacción. | | GeneralFailure | No se ha podido llevar a cabo la transacción. Se recibe este error cuando no se puede encontrar el host SMTP especificado. |

Comentarios
Los valores de la enumeración SmtpStatusCode especifican valores de estado de respuesta enviados por un servidor SMTP (Protocolo simple de transferencia de correo). Las clases SmtpException y SmtpFailedRecipientsException contienen propiedades StatusCode que devuelven valores de SmtpStatusCode. El protocolo SMTP se define en el documento RFC 2821, que está disponible en http://www.ietf.org.

Ejemplos
En el siguiente ejemplo de código se muestra un mensaje de error en la consola cuando se produce una excepción SmtpException.
public static void CreateMessageWithAttachment3(string server, string to)
{
// Specify the file to be attached and sent.
// This example assumes that a file named Data.xls exists in the
// current working directory.
string file = "data.xls";
// Create a message and set up the recipients.
MailMessage message = new MailMessage(
"ReportMailer@contoso.com",
to,
"Quarterly data report",
"See the attached spreadsheet.");
// Create the file attachment for this e-mail message.
Attachment data = new Attachment("Qtr3.xls");
// Add time stamp information for the file.
ContentDisposition disposition = data.ContentDisposition;
disposition.CreationDate = System.IO.File.GetCreationTime(file);
disposition.ModificationDate = System.IO.File.GetLastWriteTime(file);
disposition.ReadDate = System.IO.File.GetLastAccessTime(file);
// Add the file attachment to this e-mail message.
message.Attachments.Add(data);
//Send the message.
SmtpClient client = new SmtpClient(server);
// Add credentials if the SMTP server requires them.
client.Credentials = (ICredentialsByHost)CredentialCache.DefaultNetworkCredentials;
// Notify user if an error occurs.
try
{
client.Send(message);
}
catch (SmtpException e)
{
Console.WriteLine("Error: {0}", e.StatusCode);
}
finally
{
data.Dispose();
}
}
static void CreateMessageWithAttachment3( String^ server, String^ to )
{
// Specify the file to be attached and sent.
// This example assumes that a file named data.xls exists in the
// current working directory.
String^ file = L"data.xls";
// Create a message and set up the recipients.
MailMessage^ message = gcnew MailMessage( L"ReportMailer@contoso.com",to,L"Quarterly data report",L"See the attached spreadsheet." );
// Create the file attachment for this e-mail message.
Attachment^ data = gcnew Attachment("Qtr3.xls");
// Add time stamp information for the file.
ContentDisposition^ disposition = data->ContentDisposition;
disposition->CreationDate = System::IO::File::GetCreationTime( file );
disposition->ModificationDate = System::IO::File::GetLastWriteTime( file );
disposition->ReadDate = System::IO::File::GetLastAccessTime( file );
// Add the file attachment to this e-mail message.
message->Attachments->Add( data );
//Send the message.
SmtpClient^ client = gcnew SmtpClient( server );
// Add credentials if the SMTP server requires them.
client->Credentials = dynamic_cast<ICredentialsByHost^>(CredentialCache::DefaultNetworkCredentials);
// Notify user if an error occurs.
try
{
client->Send( message );
}
catch ( SmtpException^ e )
{
Console::WriteLine( L"Error: {0}", e->StatusCode );
}
finally
{
data->~Attachment();
client->~SmtpClient();
}
}

Información de versión
.NET FrameworkCompatible con: 4, 3.5, 3.0, 2.0 .NET Framework Client ProfileCompatible con: 4, 3.5 SP1

Plataformas
Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2
.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

Vea también
|