E-Mail validation on Input - what options are available

Hi, I have a requirement to validate peoples email address when captured into Navision Contact Card. Currently if there is an invalid email address contacts that register via the web-site are having issues when the web looks up the contact details in Navision.

Anyway, I was thinking of the following:

  • Use OnValidate Trigger (ofcourse) - when data capturere types contact details into Navision contact card.
  • Use Navision Code and develop some sort of function manually to validate an email address
  • OR Try to use the same XML validation string as used on the website
  • ([.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(([a-zA-Z0-9_-])*.([a-zA-Z0-9_-])+)+.
  • but use XMLDomDoc variable in Navision to somehow validate the E-Mail field in Navision using XML schema or something
  • The key benefit here for me is that the XML string above can be a setup parameter, and is probably more accurate than writing a new Navision function

Has anyone attempted something like this before? (Perhaps using XMLports is something, but I have not looked into that at all).

So am I stretching the boundries or overcomplicating a seemingly simple task, either way its a challange.

What do you meen by “setup parameter”?
mail adressess are in standard “shape” for a long time, so why do you need setup parameter (except you will use that same procedure for other validations?)

Well, you may be right, email address probably only needs one type of validation.

But, I was thinking more along the lines of being able to re-use XML validation parameters within Navision for other types of fields. Just running with an idea.

I’m interested, will you have an e-mail address in xml object/var then parse it, or have properties in xml object/var and parse pure string (actually, I’m not quite sure, why do you need xml, but that could be my problem of not knowing…)?
In first way, you will have not only to call parse/validatation function, but to transfer string to xml too…
In second, you have to only ensure that that function is globally availible (through single instace for ex.) cause of speeding up a little bit of coding, accessibility and running…

the idea is to have the XML object loaded with XML schema that and a second XML object (parse the email string to it as a parameter) then try compare the schema against the email to see if parses XML validation - and on top of this catch if it parsed.

Come to think of it, this is all sounding a bit dramatic and so I am leaning towards just putting normal navision code to validate the email.

Unless anyone out there knows of another way.

I can always come out with a more complicated solution :slight_smile:

well, if you don’t plan to upgrade your solution to be flexible and usabile for other problems, keep it simple…

Sorry if I am making thsi to simple, but why not just create an excel automation, enter the email in outlook, and check for an errror. Then send the email, and if an error messag comes back, then you knwo the email does not exist.

Its not for sending emails, its for capturing valid email addresses in the contact email address field.

I think that the confusion is where I said validate an email address where in fact I meant it should check to see if the email address is in the correct format like aaaaa@bbbb.com and if it does not have an @ sign or a “.” after the @ sign then it is not valid

We have 400+ navision users, most of which don’t pay particular attention to the data they are punching into Navision.

Probably in this case, a simple Navision funciton will have to do.

When it comes to data entry - if it can be screwed up it will eventually.

Something like this we create 3 fields seperate that they can tab thru quickly
1st is name (ex)= Harry
2nd is Domainname(ex) = Microsoft
3rd is extension(ex) = COM, Net, Org, etc

then we put it back together

Email := Name+’@’+Domain+’.’+Extension

this way they don’t have to do any @ symbols and dot’s (usually).

Everybody has their own way that suits them.

You can use your Regular Expression ([.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(([a-zA-Z0-9_-])*.([a-zA-Z0-9_-])+)+. with an RegEx-Checker like Navision RegExp.Net v1.0.

If you want to read more about E-Mail-Validation ask Google for “eMail-validation regex” or something like that.

OK, how about

EmailOK :=
(StrLen(Email) > 6) and
(Strpos(Email,‘.’) > Strpos(Email,‘@’)) and
(Strpos(Email.‘@’) > 1) and
(Strpos(Email,‘.’) < (Strlen(Email) - 2));

Assumptions Min address lend - a@bc.df
This won’t handle dots in adresses, you need to work that one out eg john.smith@xyz.com would not pass but it will get you started.

The beauty ofthis is you can just put the code in the source expresion of an Icon next to the Email address field, with the standard email icon, and a big red X as the bitmaps.

But in reality as Harry says, somewhere down the line it will break anyway, so may be his idea of forcing a validation process through entry will solve a large percentage of issues.

I just found a nice article: C# Regex - Parsing Email With Regular Expressions. This article has a realy nice RegEx-pattern for e-mail-validation. Try to test your pattern against the given addresses in this article…

I like this RegEx thing [:D]

So far I have found the following expression very usefull. Thanks very much for your input I think I will experiment a bit more (I found that it takes very long if you ommit the “@” sign). But am likely to use this. Much apprecieated [;)]

Anyway heres the expression (I put it in a Text Constant):




Hi! I have been keenly following this thread because I have an automation of creating invoices to over 300 clients, on over 4000 products. The invoices are then saved in a folder as adobe files and automatically send to respective emails. This used to be done by a user.

My challenge is that the automation is facing a challenge of invalid email addresses, requiring a lot of user intervention whenever it stops. The user has too go into the sales header, look for the invalid email address and remove or correct it, and re-run the routine. This is time consuming.

so am thinking of a solution just like this here: to validate email data at entry. in fact, I wonder why its not standard in NAV, when everything else is such as dates et cetera!

The solution above is not very amusing for me, but I will keep looking for options until I have no other.


Hi Robert,

It’s been a long while since I’ve looked at this post and believe things have progressed much in the past 8 years from the original post [:)]

Here are my thoughts, in general on email addresses and emailing, hopefully this gives you some useful information:

  • Firstly, the solution I’ve used most often using NAV 2009 or earlier Classic Client is to simply validate the email address on input with some basic NAV code. I agree, it would have been nice if it included validation by default.
  • If you are using RTC then I think the ExtendedDatatype=Email option provides some basic email format checks anyway.
  • With regards to emailing solution and Classic Client I tend to go between standard NAV SMTP, a custom SQL emailing solution we built or using a 3rd party integrated application like ZetaDocs or Planet Press. Selecting the right solution based upon business requirement. In fact we have clients that use all 3 options in one company.
  • One common problem we encounter is how to solve a valid format email address where the address does not actually exist. So you send the email but it ‘bounces’ and we catch the bounce back email and update NAV as email sending failed. Its a long discussion this alone.

In terms of your specific automation solution its sounds like there is room for improvement. If your routines do not cater for and force you to do manual corrections and re-run the entire process then I would say looking at changing or modifying your solution might be what you need.