1 /// <summary>
2 /// Validates an input string as a properly formatted email address.
3 /// </summary>
4 /// <param name="eMailAddress">
5 /// System.String, represents
6 /// the email address to be interigates
7 /// </param>
8 public bool isValidEmailAddress( System.String eMailAddress )
9 {
10 /* expression string */
11 System.Text.StringBuilder _stringBuilder = new System.Text.StringBuilder();
12 _stringBuilder.Append( @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" ) ;
13 _stringBuilder.Append( @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" ) ;
14 _stringBuilder.Append( @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$" ) ;
15
16 /* regular expression */
17 System.Text.RegularExpressions.Regex _regularExpression = new System.Text.RegularExpressions.Regex( _stringBuilder.ToString() ) ;
18
19 /* interigate the string */
20 if ( _regularExpression.IsMatch( (string) eMailAddress ) )
21 {
22 /* is a valid email address */
23 return ( true ) ;
24 }
25 else
26 {
27 /* is not a valid email address */
28 return ( false ) ;
29 }
30 }