0 votes

Hello everyone, I have the following issue:

If for any reason the combination Connect (or ConnectSSL) or UseBestLogin fail, there is only a standard exception back, or a ImapResponseException.

The associated message is correct, and we log it to a log file, so we know what really happened, but we need to re-map different reasons to localized strings for a client GUI.

At the moment I can only display a unique localized string, which basically says to check URL, Login, Password or other...I cannot offer specific error messages.

Is there any way to get the reason of a connect-login failure, without using the associated exception message?

Before I was using an old POP3 library (I say this just to make an example) and I had several Exceptions back, corresponding to several possible failure reasons. Then I could map them to the localized strings for the GUI.

Thanks a lot for support,
Emilio

by (220 points)

1 Answer

+1 vote

Connect (ConnectSSL) and UseBestLogin (or any other login method) are two different things. First establishes a connection to the server, while the second authenticates the user.

If there is a problem with the connection (incorrect server address, port, no Internet connection, SSL certificate problem, server returning an error message just after you connect) you'll get an exception from the first method (Connect/ConnectSSL).

If there is an authentication failure, you'll get an exception from the second method (UseBsetLogin/Login).

In both cases Imap/Pop3/SmtpResponseException means. that this is the server. that is reporting an error -you can get the server response using a Message property and a Response property.

Any other exception is wrapped in ServerException - you can use InnerException to examine the root cause (e.g. SocketException).

by (301k points)
Thanks,
actually I was doing some experiment on this.
The InnerException (in the Connect case) is always a SocketException, the message does not help directly the user, it is only logged to a file (not visible to the user via the GUI) but in fact there is a Windows Error Code also, then I can find exactly what happened without using the message.

Thanks,
Emilio
...