SmtpStatusCode Enumerazione

Definizione

Specifica il risultato ottenuto inviando messaggi di posta elettronica mediante la classe SmtpClient.

public enum class SmtpStatusCode
public enum SmtpStatusCode
type SmtpStatusCode = 
Public Enum SmtpStatusCode
Ereditarietà
SmtpStatusCode

Campi

BadCommandSequence 503

I comandi non sono stati inviati nella sequenza corretta.

CannotVerifyUserWillAttemptDelivery 252

L'utente specificato non è locale, ma il servizio SMTP di destinazione ha accettato il messaggio e ha tentato di recapitarlo. Questo codice di stato è definito nel documento RFC 1123, disponibile all'indirizzo https://www.ietf.org.

ClientNotPermitted 454

Il client non è stato autenticato o non è autorizzato a inviare la posta mediante l'host SMTP specificato.

CommandNotImplemented 502

Il servizio SMTP non implementa il comando specificato.

CommandParameterNotImplemented 504

Il servizio SMTP non implementa il parametro di comando specificato.

CommandUnrecognized 500

Il servizio SMTP non riconosce il comando specificato.

ExceededStorageAllocation 552

Il messaggio è troppo grande per essere memorizzato nella cassetta postale di destinazione.

GeneralFailure -1

Non è possibile eseguire la transazione. Si riceve questo errore quando non è possibile trovare l'host SMTP specificato.

HelpMessage 214

È stato restituito un messaggio della Guida dal servizio.

InsufficientStorage 452

Il servizio SMTP non ha spazio di archiviazione sufficiente per completare la richiesta.

LocalErrorInProcessing 451

Il servizio SMTP non è in grado di completare la richiesta. Questo errore può verificarsi se non è possibile risolvere l'indirizzo IP del client, ovvero se una ricerca inversa ha avuto esito negativo. È anche possibile ricevere questo errore se il dominio del client è stato identificato come inoltro aperto o origine aperta per la posta indesiderata (spam). Per informazioni dettagliate vedere il documento RFC 2505, disponibile all'indirizzo https://www.ietf.org.

MailboxBusy 450

La cassetta postale di destinazione è in uso.

MailboxNameNotAllowed 553

La sintassi usata per specificare la cassetta postale di destinazione non è corretta.

MailboxUnavailable 550

Non è possibile trovare o accedere alla cassetta postale di destinazione.

MustIssueStartTlsFirst 530

Il server SMTP è stato configurato per accettare solo connessioni TLS e il client SMTP sta tentando di connettersi usando una connessione non TLS. Per risolvere questo problema, l'utente deve impostare EnableSsl=true sul client SMTP.

Ok 250

Il messaggio di posta elettronica è stato inviato correttamente al servizio SMTP.

ServiceClosingTransmissionChannel 221

È in corso la chiusura del canale di trasmissione da parte del servizio SMTP.

ServiceNotAvailable 421

Il servizio SMTP non è disponibile. È in corso la chiusura del canale di trasmissione da parte del server.

ServiceReady 220

Il servizio SMTP è pronto.

StartMailInput 354

Il servizio SMTP è pronto per ricevere il contenuto del messaggio di posta elettronica.

SyntaxError 501

La sintassi usata per specificare un comando o un parametro non è corretta.

SystemStatus 211

Risposta contenente lo stato del sistema o informazioni della Guida.

TransactionFailed 554

La transazione non è riuscita.

UserNotLocalTryAlternatePath 551

La cassetta postale dell'utente non si trova sul server di destinazione. È necessario effettuare nuovamente l'invio usando le informazioni sull'indirizzo specificate.

UserNotLocalWillForward 251

La cassetta postale dell'utente non si trova nel server di destinazione. Il messaggio di posta elettronica viene inoltrato dal server.

Esempio

Nell'esempio di codice seguente viene visualizzato un messaggio di errore nella console quando viene generato un SmtpException oggetto .

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 email 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 email 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();
   }

}
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 email 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 email 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();
    }
}

Commenti

I valori dell'enumerazione SmtpStatusCode specificano i valori di stato della risposta inviati da un server SMTP (Simple Mail Transfer Protocol). Le SmtpException classi e SmtpFailedRecipientsException contengono StatusCode proprietà che restituiscono SmtpStatusCode valori.

SMTP è definito in RFC 2821 disponibile in https://www.ietf.org.

Si applica a