Skip to content

IsEmailValid ​

The IsEmailValid function checks the syntax of the string aValue, to confirm that the email address has a valid format.

IsEmailValid does not ping the specified email address, and does not confirm that it is a current email address for the specified email provider.

But in terms of syntax, the function checks the email address to such as the following to ensure that it is syntactically correct -

  • The address has an at sign (@) prefixing the name of the email provider.
  • The email address does not have two (2) dots on a row.
  • There is no dot next to the @ sign.

Declaration: Function IsEmailValid( const aValue : string) : boolean;

Several examples of the use of the function.

pascal
procedure ScriptEvent(var Value:Variant);
var
  Str0, Str5, Str1 : string;
begin
 //This will return True
  Str0 := 'thatredcar@gmail.com'
 If IsEmailValid(Str0) = true then
    LogInfo('The email address '+Str0+' is valid.')
 else
    LogInfo('The email address is invalid.');

 //This will return True
  Str5 := 'thatredcar@gmail.co'
 If IsEmailValid(Str5) = true then
    LogInfo('The email address '+Str5+' is valid.')
 else
    LogInfo('The email address is invalid.');

 //This will return False
  Str1 := 'thatredcar.@gmail.com'
 If IsEmailValid(Str1) = true then
    LogInfo('The email address '+Str1+' is valid.')
 else
    LogInfo('The email address is invalid.');

 //This will return False
  Str5 := 'some..body@soemwhere.com'
 If IsEmailValid(Str5) = true then
    LogInfo('The email address '+Str5+' is valid.')
 else
    LogInfo('The email address is invalid.');

end;