SmtpStatusCode Enum

Definisi

Menentukan hasil pengiriman email dengan menggunakan SmtpClient kelas .

public enum class SmtpStatusCode
public enum SmtpStatusCode
type SmtpStatusCode = 
Public Enum SmtpStatusCode
Warisan
SmtpStatusCode

Bidang

BadCommandSequence 503

Perintah dikirim dalam urutan yang salah.

CannotVerifyUserWillAttemptDelivery 252

Pengguna yang ditentukan tidak lokal, tetapi layanan SMTP penerima menerima pesan dan mencoba mengirimkannya. Kode status ini didefinisikan dalam RFC 1123, yang tersedia di https://www.ietf.org.

ClientNotPermitted 454

Klien tidak diautentikasi atau tidak diizinkan untuk mengirim email menggunakan host SMTP yang ditentukan.

CommandNotImplemented 502

Layanan SMTP tidak menerapkan perintah yang ditentukan.

CommandParameterNotImplemented 504

Layanan SMTP tidak menerapkan parameter perintah yang ditentukan.

CommandUnrecognized 500

Layanan SMTP tidak mengenali perintah yang ditentukan.

ExceededStorageAllocation 552

Pesan terlalu besar untuk disimpan di kotak surat tujuan.

GeneralFailure -1

Transaksi tidak dapat terjadi. Anda menerima kesalahan ini ketika host SMTP yang ditentukan tidak dapat ditemukan.

HelpMessage 214

Pesan Bantuan dikembalikan oleh layanan.

InsufficientStorage 452

Layanan SMTP tidak memiliki penyimpanan yang memadai untuk menyelesaikan permintaan.

LocalErrorInProcessing 451

Layanan SMTP tidak dapat menyelesaikan permintaan. Kesalahan ini dapat terjadi jika alamat IP klien tidak dapat diselesaikan (artinya, pencarian terbalik gagal). Anda juga dapat menerima kesalahan ini jika domain klien telah diidentifikasi sebagai relai terbuka atau sumber untuk email yang tidak diminta (spam). Untuk detailnya, lihat RFC 2505, yang tersedia di https://www.ietf.org.

MailboxBusy 450

Kotak surat tujuan sedang digunakan.

MailboxNameNotAllowed 553

Sintaks yang digunakan untuk menentukan kotak surat tujuan salah.

MailboxUnavailable 550

Kotak surat tujuan tidak ditemukan atau tidak dapat diakses.

MustIssueStartTlsFirst 530

Server SMTP dikonfigurasi untuk hanya menerima koneksi TLS, dan klien SMTP mencoba terhubung dengan menggunakan koneksi non-TLS. Solusinya adalah agar pengguna mengatur EnableSsl=true pada Klien SMTP.

Ok 250

Email berhasil dikirim ke layanan SMTP.

ServiceClosingTransmissionChannel 221

Layanan SMTP menutup saluran transmisi.

ServiceNotAvailable 421

Layanan SMTP tidak tersedia; server menutup saluran transmisi.

ServiceReady 220

Layanan SMTP sudah siap.

StartMailInput 354

Layanan SMTP siap menerima konten email.

SyntaxError 501

Sintaks yang digunakan untuk menentukan perintah atau parameter salah.

SystemStatus 211

Status sistem atau balasan Bantuan sistem.

TransactionFailed 554

Transaksi gagal.

UserNotLocalTryAlternatePath 551

Kotak surat pengguna tidak terletak di server penerima. Anda harus mengirim ulang menggunakan informasi alamat yang disediakan.

UserNotLocalWillForward 251

Kotak surat pengguna tidak terletak di server penerima; server meneruskan email.

Contoh

Contoh kode berikut menampilkan pesan kesalahan ke konsol saat SmtpException dilemparkan.

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

Keterangan

Nilai dalam SmtpStatusCode enumerasi menentukan nilai status balasan yang dikirim oleh server Simple Mail Transfer Protocol (SMTP). Kelas SmtpException dan SmtpFailedRecipientsException berisi StatusCode properti yang mengembalikan SmtpStatusCode nilai.

SMTP ditentukan dalam RFC 2821 tersedia di https://www.ietf.org.

Berlaku untuk