Reputation: 799
So I have an application which basically sends an email out, but I want to be able to have multiple users using it, and I need it to check if their login details are correct, which ideally need to be done when entered, but that's not essential, as it sends the email would be fine as well.
I've looked up how to do it, and I read about using an SmtpException
, my issue is that I don't actually know how to use it to check if the password is the thing causing the issue.
The other way I found was to use sockets and to check with a tcp/ip
layer, however as the program is bespoke for a company, I don't know exactly how their server works, and therefore don't really want to use this method.
Thanks for all your help
Upvotes: 0
Views: 675
Reputation: 1026
The SmtpException thrown will include a status code. See SmptException.StatusCode
It will return an enumeration value of type SmtpStatusCode.
I believe the one you're looking for (to indicate a bad login) is ClientNotPermitted.
To confirm, you can try a test program and provide invalid credentials . . .
Hope that help!
Upvotes: 1