Examples Delphi

Here is a little function that will validate an EMail-address.
It will check the EMail:s basic construction with five different tests.
You cannot, of course, be sure that the address will be a working one, but at least it will have all chances to it!
Here is what it will check:
That the "@"-character is present.
That there's at least one character before "@".
That there's at least one dot (".") after "@".
That there's at least one character between "@" and the dot.
That there's at least one character after the dot.
function EMailValid(EMail: string): Boolean;
begin
Result:= false;
if Pos('@', EMail) > 0 then
if Length(Copy(EMail, 1, Pos('@', EMail) - 1)) > 0 then
if Pos('.', Copy(EMail, Pos('@', EMail) + 1, 1000)) > 0 then
if Length(Copy(EMail, Pos('@', EMail) + 1, Pos('.', Copy(EMail, Pos('@',
EMail) + 1, 1000)))) > 0 then
if Length(Copy(EMail, Pos('.', EMail) + 1, 1000)) > 0 then
Result:= true;
end;