Check e-mail address?

Posted on 2004-04-22
Medium Priority
Last Modified: 2010-05-02
Hi all
Does anyone has a function/sub in VB to check an email address is good or bad?

Question by:melodiesoflife
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
LVL 18

Accepted Solution

Sethi earned 300 total points
ID: 10887757

Expert Comment

ID: 10887758
If you're looking to verify if it's in the traditional user@dom.ain format, that's easy enough... But if you want to know if it's an actual working address, you'll have to actually send something to it.

To verify the format, I would do an Instr search to find the @, iterate through the part before it to check for alphanumeric only, then split the other part by periods (.) and check for alphanumerics and dashes surrounded by alphanumerics.

Expert Comment

ID: 10887769
Hmm, looking at Sethi's comment, it's nice to be proven wrong.
LVL 19

Expert Comment

ID: 10887841
YOu have to correct the sysntaxes:

function checkemail(strEmail) as boolean
    If Len(strEMail) < 5 Exit function                              ' Minimum length check
    If InStr(strMail, "@", 1) = 1 Exit function                  ' Must contain @ symbol
    If InStr(strMail, ".", 1) = 1 Exit function                    ' Must contain . symbol

    checkemail = true
end function

Author Comment

ID: 10895742
Thank all.

I have wrote it for myself

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

649 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