Validatiom email
Someone know where hava a example og validation of email.
Thank you!
Answers
This is the regex for email addresses in expresso:
([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})
So something like
if (Regex.IsMatch(string, @"([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})"))
will return true if string is an email address
Don't forget to put using System.Text.RegularExpressions;
All Replies
What are you hoping to validate, an email *address*, or something else ? Regex to validate email addresses are pretty common, I think expresso even has one built in.
I'm needing that when I client put or email in my form my system talk to me If or email is true else false. Only it!
Thank you a lot! again
This is the regex for email addresses in expresso:
([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})
So something like
if (Regex.IsMatch(string, @"([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})"))
will return true if string is an email address
Don't forget to put using System.Text.RegularExpressions;
- I know I'm a bit in late with this message, but I'm posting it anyway for future readers who may find it useful.
In my company we use EmailVerify.NET (http://www.emailverify.net), a Microsoft .NET component which supports e-mail syntax checking, domain MX test and mailbox validation too.
E-mail validation up to the mailbox level is easy as writing the following code block:
var verifier = new EmailVerifier(); var result = verifier.Verify("me@example.com", VerificationLevel.Mailbox); if (result.IsSuccess) { // Go on, send the message }
Additional code samples can be found here.
From their home page:
EmailVerify.NET is a powerful .NET component which verifies email addresses using various techniques, including:- Syntax verification, according to RFC 2821 and RFC 2822
- MX record lookup
- Disposable email address (DEA) validation
- SMTP availability check
- Mailbox existence check, with greylisting support
- Catch-all test
It is completely written in managed code (C#) and is compliant with the Common Language Specification (CLS), so it can be used with any other .NET language, including VB.NET, C++/CLI, J#, IronPython, IronRuby and F#.
The price for this component is very small (less than 50 bucks) and their support is one of the greatest I've ever found for a small software company like they are.
Hope this helps.


