Email address verification in
BOOL Isvalidemail (String Email) {{ var trimmedemail = email.trim (); if (Trimmedemail.endswith (".") {{ Return false; @TK-421 Suggestion } try { var addr = new system.net.mail.mailddress (email); Return addr.address == trimmedemail; } catch { Return false; } }
bool IsValidEmail(string email)
{
var trimmedEmail = email.Trim();
if (trimmedEmail.EndsWith(".")) {
return false; // @TK-421 建议
}
try {
var addr = new System.Net.Mail.MailAddress(email);
return addr.Address == trimmedEmail;
}
catch {
return false;
}
}
Other considerations
error alarm:
This method aims to provide accurate verification without inconsistency (the invalid address is recognized as a valid address).System.net.mail.Mailaddress document
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3