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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month12 days, 17 hours left to enroll

777 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