473,386 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Validating emails

Hi

I have this problem that client users enter emails incorrectly due to type
and either the domain name is invalid (Microsot.com instead of
Microsoft.com) or the syntax of the email (user'domain.com instead of
us**@domain.com). Is there any way to ensure a) email syntax is correct and
b) reverse dns or any other check to highlight invalid domain names?

Thanks

Regards
Sep 2 '06 #1
4 1813


public const string
RegexValidEMail = @"^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$";
static public bool IsValidRegexValidEMail (string ValueToTest)
{ return Regex.IsMatch(ValueToTest, RegexValidEMail); }
Sep 2 '06 #2
That's C#. Translated to VB:

Imports System.Text.RegularExpressions

Public Function IsValidRegexValidEMail(ByVal ValueToTest As String) As
Boolean
Const RegexValidEMail As String =
"^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$"
IsValidRegexValidEMail = Regex.IsMatch(ValueToTest, RegexValidEMail)
End Function

Regular expression doesn't check the length of the address and may miss
few valid addresses with special chars. See
http://en.wikipedia.org/wiki/E-mail_address

Checking domains requires a third party component as far as I know. If
someone
knows a way how to do it in VB I'd like to know too.

In the first place checking domains (or MX records) may not be feasible. It
tends to
be slow unless you have only a few email address.

- Timo
<ne***************@charter.netwrote in message
news:Vc****************@newsfe04.lga...
>

public const string
RegexValidEMail =
@"^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$";
static public bool IsValidRegexValidEMail (string ValueToTest)
{ return Regex.IsMatch(ValueToTest, RegexValidEMail); }

Sep 2 '06 #3
"John" <Jo**@nospam.infovis.co.ukschrieb:
I have this problem that client users enter emails incorrectly due to type
and either the domain name is invalid (Microsot.com instead of
Microsoft.com) or the syntax of the email (user'domain.com instead of
us**@domain.com). Is there any way to ensure a) email syntax is correct
and b) reverse dns or any other check to highlight invalid domain names?
Parsing Email Addresses using an RFC822 Compliant Address Validator
<URL:http://www.codeproject.com/csharp/RFC822Validator.asp>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Sep 2 '06 #4
I'm not an expert with email, but, here is how I'd do it...

Step1] Do the RegEd code to check format of email.
Step2] I'd figure out a way to test if the email address is valid by sending
it and checking the receipt of the email (if this can be done in .net or via
your email service).
Step3] If the email is valid then add it to a database table.
Step4] On all future email send commands then do a lookup against the
database table for the email. If email has been previously sent with out
issues then all user to keep going and send the email. Otherwise, kick up a
message box asking user if they have a valid email address.

You could also do a check against your global address book in your email
system (Outlook) or in Active Directory. If your using Acitve Directory
then you can use .net code to see your network wide addresses if you have
admin authority.

Hope this helps! JerryM
Oct 13 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Alex Bink | last post by:
Hi, I have a validating event on a textbox in which I want to prevent the user to leave the textbox without entering the right data. Only if he clicks on another specific control he is allowed...
2
by: orekinbck | last post by:
Hi There I have spent alot of time trying to get a masked text box to validate e-mails, but with no success. Mainly because I can't figure out how to account for the wide variety of different...
11
by: tshad | last post by:
I have 4 dropdown boxes (fromDay, fromMonth, ToDay and ToMonth) I want to be able to test to make sure that the dates are valid and the the From dates are < the To dates. When I add the...
0
by: Joe | last post by:
Hi For a while now I have been finding postings of problems with the validating event not firing on controls properly. I too had this problem. The event would fire when clicking on another...
2
by: Chris Dunaway | last post by:
I have a form with a textbox and numerous panels, buttons and other controls. I have handled the textbox Validating and Validated events. The textbox will hold a filename. In the validating...
0
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852...
3
by: oopaevah | last post by:
Hello To prevent scross site scripting I am validating each value in the Request.Params collection against the following regular expression : ^*$ This only allows the following characters :...
4
by: SAL | last post by:
I am using a RegularExpressionValidator control on my ASP page, and I have the ValidationExpression property set to "Internet E-mail Address". The email address is valiated when the user puts in a...
1
by: John | last post by:
Hi I have this problem that client users enter emails incorrectly due to type and either the domain name is invalid (Microsot.com instead of Microsoft.com) or the syntax of the email...
0
by: =?Utf-8?B?Q2hhcmxlcw==?= | last post by:
Like many people, I normally use Yahoo! Mail via the web and like to keep all my emails stored on the Yahoo! server. However sometimes I can’t get access to a PC/the web and I download my emails...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.