0 votes

I'm using mail.dll, but i want to know all the error codes that i could get when something happens when i try to connect pop3, imap or smtp. can you help me with that?

by

1 Answer

0 votes

There are no such error codes. If there is a problem with the connection to the email server you'll get a standard .NET exception.

If there is a problem with logging-in you should catch appropriate exception:
Pop3ResponseException, SmtpResponseException or ImapResponseException.

All exception classes have Response property.

SMTP

To get the response code for SMTP use
SmtpResponse.Status (e.g SmtpResponseStatus.Positive for code 200),
SmtpResponse.EnhancedStatusCode (e.g. "2.1.0") and
SmtpResponse.Code (e.g. 200) in case of SMTP;

POP3

To get the response code for POP3 use
Pop3Response.Status (e.g. Pop3ResponseStatus.Positive for +OK)

IMAP

To get the response code for IMAP use
ImapResponse.Status (e.g. ImapResponseStatus.Positive for OK) and
ImapResponse.AdditionalResponse (e.g. "BADCHARSET")

by (301k points)
...