This documentation is archived and is not being maintained.
SmtpStatusCode Enumeration
Visual Studio 2010
Specifies the outcome of sending e-mail by using the SmtpClient class.
Assembly: System (in System.dll)
| 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. |
The values in the SmtpStatusCode enumeration specify reply status values sent by a Simple Mail Transfer Protocol (SMTP) server. The SmtpException and SmtpFailedRecipientsException classes contain StatusCode properties that return SmtpStatusCode values.
SMTP is defined in RFC 2821 available at http://www.ietf.org.
The following code example displays an error message to the console when an SmtpException is thrown.
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(); } }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), 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.
Show: