I've an application that's getting gmail email address and password from a database table, and verifying it, before sending any message using those emails, but the following part is returning me an exception, whenever there's any validation error occurs.
new System.Net.NetworkCredential(username, password);
How can I verify that username and password are correct without throwing any exception at runtime?
This answer was provided in order to ascertain the exact nature of the problem as the code originally posted was insufficient.
According to the documentation the constructor doesn't raise an exception - unless you are using the version that takes a
SecureString
for the password.In that case it raises a
NotSupportedException
if the SecureString class is not supported.What exception is actually being raised?