Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how to validate email id without using regular expression

Posted on 2008-06-26
6
Medium Priority
?
1,206 Views
Last Modified: 2013-12-16
how to validate email id without using regular expressions.
USING:- MICROSOFT VISUAL STUDIO2005
0
Comment
Question by:pooja
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 336 total points
ID: 21873722
Can I ask you why you don't want to use a regular expressions?

You can always use those rules:
-requires a @ character
-the @ character cannot be the first one
-a . is required after the @
-at least 1 character is required between the @ and the .
-at least 1 character is required after the .
0
 
LVL 53

Assisted Solution

by:Dhaest
Dhaest earned 332 total points
ID: 21873724
Why aren't you using regular expressoins for it ?
Imports System.Text.RegularExpressions     
Function EmailAddressCheck(ByVal emailAddress As String) As Boolean
Dim pattern As String = "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"        
Dim emailAddressMatch As Match = Regex.Match(emailAddress, pattern)        
If emailAddressMatch.Success Then
            EmailAddressCheck = True
Else            
            EmailAddressCheck = False        
End If     
End Function

Open in new window

0
 
LVL 7

Assisted Solution

by:joesthebighmoe
joesthebighmoe earned 332 total points
ID: 21874998
You can rely on the .Net framework....



public bool IsEmailValid(string iEmail)
{
  bool oIsEmailValid = true; //until proven false
    try
    {
      MailMessage Msg = new MailMessage();
      Msg.To.Add(iEmail);
    }
    catch
    {
      //Email addresses cannot be added if the mail message thinks they are invalid
      oIsEmailValid = false;
    }
    
    return oIsEmailValid;
}

Open in new window

0
 
LVL 7

Expert Comment

by:joesthebighmoe
ID: 22204048
Usually I would not bother with this since so much opinion is involved, however your recommendation seems strange.
The user asked how to validate email without regular expressions.
emoreau & Dhaest both asked why you would not want to use regular expressions.
I actually answered his question.
That said, do what you will.
-Cheers,
Joe
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question