SmtpStatusCode 列挙型

定義

電子メールの送信結果を、SmtpClient クラスを使用して指定します。

public enum class SmtpStatusCode
public enum SmtpStatusCode
type SmtpStatusCode = 
Public Enum SmtpStatusCode
継承
SmtpStatusCode

フィールド

BadCommandSequence 503

コマンドが不正な順序で送信されました。

CannotVerifyUserWillAttemptDelivery 252

指定したユーザーはローカルではありませんが、受信側の SMTP サービスはそのメッセージを受け入れ、配信を試みました。 このステータス コードは、RFC 1123 (https://www.ietf.org を参照) で定義されています。

ClientNotPermitted 454

クライアントが認証されなかったか、指定した SMTP ホストを使用したメールの送信が許可されていません。

CommandNotImplemented 502

SMTP サービスは指定したコマンドを実装していません。

CommandParameterNotImplemented 504

SMTP サービスは指定したコマンド パラメーターを実装していません。

CommandUnrecognized 500

SMTP サービスは指定したコマンドを認識していません。

ExceededStorageAllocation 552

メッセージが大きすぎて、送信先のメールボックスに格納できません。

GeneralFailure -1

トランザクションを発行できませんでした。 指定した SMTP ホストが見つからない場合にこのエラーが発生します。

HelpMessage 214

サービスによってヘルプ メッセージが返されました。

InsufficientStorage 452

SMTP サービスには、要求を完了するために必要な容量のストレージがありません。

LocalErrorInProcessing 451

SMTP サービスは要求を完了できません。 このエラーは、クライアントの IP アドレスが解決できない (つまり、逆引き参照の失敗) 場合に発生します。 クライアントのドメインが、第三者中継や迷惑メール (SPAM) の送信元として識別されている場合にも、このエラーが発生します。 詳細については、RFC 2505 (https://www.ietf.org) を参照してください。

MailboxBusy 450

送信先のメールボックスが使用中です。

MailboxNameNotAllowed 553

送信先のメールボックスの指定に使用した構文が正しくありません。

MailboxUnavailable 550

送信先のメールボックスが見つからなかったかアクセスできませんでした。

MustIssueStartTlsFirst 530

SMTP サーバーが TLS 接続のみを受け入れるように構成されており、SMTP クライアントが非 TLS 接続を使用して接続しようとしています。 これを解決するには、そのユーザーについては、SMTP クライアントで EnableSsl=true を設定します。

Ok 250

電子メールは SMTP サービスに正常に送信されました。

ServiceClosingTransmissionChannel 221

SMTP サービスの伝送チャネルが閉じられています。

ServiceNotAvailable 421

SMTP サービスが利用できません。サーバーの伝送チャネルが閉じられています。

ServiceReady 220

SMTP サービスの準備が整っています。

StartMailInput 354

SMTP サービスは、電子メールの内容を受信できる状態です。

SyntaxError 501

コマンドまたはパラメーターの指定に使用した構文が正しくありません。

SystemStatus 211

システムの状態またはシステム ヘルプの返答です。

TransactionFailed 554

トランザクションに失敗しました。

UserNotLocalTryAlternatePath 551

ユーザー メールボックスが受信側のサーバー上に配置されていません。 提供されたアドレス情報を使用して再送信する必要があります。

UserNotLocalWillForward 251

ユーザー メールボックスが受信側のサーバー上に配置されていません。サーバーは電子メールを転送します。

次のコード例では、スローされたときにコンソールにエラー メッセージを SmtpException 表示します。

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

注釈

列挙の値は、 SmtpStatusCode 簡易メール転送プロトコル (SMTP) サーバーによって送信される応答状態の値を指定します。 クラスSmtpExceptionには、SmtpFailedRecipientsException値を返すSmtpStatusCodeプロパティが含まれていますStatusCode

SMTP は RFC 2821 で定義されています https://www.ietf.org

適用対象