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-адрес клиента (то есть при сбое обратного просмотра). Эта ошибка также может возникнуть, если домен клиента настроен на открытую ретрансляцию и служит источником нежелательных сообщений электронной почты (спама). Дополнительные сведения см. в RFC 2505 по адресу https://www.ietf.org.

MailboxBusy 450

Почтовый ящик назначения уже используется.

MailboxNameNotAllowed 553

Для указания почтового ящика назначения используется неправильный синтаксис.

MailboxUnavailable 550

Почтовый ящик назначения не найден или недоступен.

MustIssueStartTlsFirst 530

SMTP-сервер настроен на прием только TLS-подключений, а клиент SMTP пытается подключиться без использования TLS-подключения. Чтобы устранить эту проблему, установите для этого пользователя параметр EnableSsl=true в клиенте SMTP.

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 StatusCode свойства, возвращающие SmtpStatusCode значения.

SMTP определен в RFC 2821, доступно по адресу https://www.ietf.org.

Применяется к