SmtpStatusCode 枚举

定义

使用 SmtpClient 类指定发送电子邮件的结果。Specifies the outcome of sending email by using the SmtpClient class.

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

字段

BadCommandSequence 503

发送命令的顺序不正确。The commands were sent in the incorrect sequence.

CannotVerifyUserWillAttemptDelivery 252

指定的用户不是本地用户,但接收 SMTP 服务接受了邮件并试图将其传送。The specified user is not local, but the receiving SMTP service accepted the message and attempted to deliver it. 此状态码在 RFC 1123 中定义,可在 https://www.ietf.org 处获取。This status code is defined in RFC 1123, which is available at https://www.ietf.org.

ClientNotPermitted 454

客户端未经过身份验证或不允许使用指定的 SMTP 主机发送邮件。The client was not authenticated or is not allowed to send mail using the specified SMTP host.

CommandNotImplemented 502

SMTP 服务无法实现指定的命令。The SMTP service does not implement the specified command.

CommandParameterNotImplemented 504

SMTP 服务无法实现指定的命令参数。The SMTP service does not implement the specified command parameter.

CommandUnrecognized 500

SMTP 服务无法识别指定的命令。The SMTP service does not recognize the specified command.

ExceededStorageAllocation 552

消息太大,无法存储在目标邮箱中。The message is too large to be stored in the destination mailbox.

GeneralFailure -1

事务无法发生。The transaction could not occur. 找不到指定的 SMTP 主机时,会收到此错误提示信息。You receive this error when the specified SMTP host cannot be found.

HelpMessage 214

服务返回的帮助消息。A Help message was returned by the service.

InsufficientStorage 452

SMTP 服务没有足够的存储空间来完成该请求。The SMTP service does not have sufficient storage to complete the request.

LocalErrorInProcessing 451

SMTP 服务无法完成请求。The SMTP service cannot complete the request. 如果无法解析客户端的 IP 地址(即反向查找失败),则可能出现此错误。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 email (spam). 有关详细信息,请参阅 RFC 2505,可在 https://www.ietf.org 处获取。For details, see RFC 2505, which is available at https://www.ietf.org.

MailboxBusy 450

目标邮箱正在使用中。The destination mailbox is in use.

MailboxNameNotAllowed 553

用于指定目标邮箱的语法不正确。The syntax used to specify the destination mailbox is incorrect.

MailboxUnavailable 550

目标邮箱找不到或无法访问。The destination mailbox was not found or could not be accessed.

MustIssueStartTlsFirst 530

SMTP 服务器配置为仅接受 TLS 连接,并且 SMTP 客户端正在尝试使用非 TLS 连接进行连接。The SMTP server is configured to accept only TLS connections, and the SMTP client is attempting to connect by using a non-TLS connection. 解决方案是让用户在 SMTP 客户端上设置 EnableSsl = true。The solution is for the user to set EnableSsl=true on the SMTP Client.

Ok 250

电子邮件已成功发送至 SMTP 服务。The email was successfully sent to the SMTP service.

ServiceClosingTransmissionChannel 221

SMTP 服务正在关闭传输通道。The SMTP service is closing the transmission channel.

ServiceNotAvailable 421

SMTP 服务不可用;服务器正在关闭传输通道。The SMTP service is not available; the server is closing the transmission channel.

ServiceReady 220

SMTP 服务已准备就绪。The SMTP service is ready.

StartMailInput 354

SMTP 服务已准备好接收电子邮件内容。The SMTP service is ready to receive the email content.

SyntaxError 501

用于指定命令或参数的语法不正确。The syntax used to specify a command or parameter is incorrect.

SystemStatus 211

系统状态或系统帮助回复。A system status or system Help reply.

TransactionFailed 554

事务失败。The transaction failed.

UserNotLocalTryAlternatePath 551

用户邮箱不位于接收服务器上。The user mailbox is not located on the receiving server. 应使用提供的地址信息重新发送。You should resend using the supplied address information.

UserNotLocalWillForward 251

用户邮箱不在接收服务器上;服务器会转发该电子邮件。The user mailbox is not located on the receiving server; the server forwards the email.

示例

下面的代码示例在SmtpException引发时会向控制台显示一条错误消息。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 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) 服务器发送的答复状态值。The values in the SmtpStatusCode enumeration specify reply status values sent by a Simple Mail Transfer Protocol (SMTP) server. SmtpException和类包含StatusCode返回值SmtpStatusCode的属性。 SmtpFailedRecipientsExceptionThe SmtpException and SmtpFailedRecipientsException classes contain StatusCode properties that return SmtpStatusCode values.

在的 RFC 2821 https://www.ietf.org中定义了 SMTP。SMTP is defined in RFC 2821 available at https://www.ietf.org.

适用于