cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Thananjeyan_M
Level 6

how to validate email address is correct or not in installscript?

Hi

I want to check the given email address (e.g abc@gmail.com) is correct or wrong in installscript.
Is it Possible in Installscript?


thanks,
Thananjeyan
Labels (1)
0 Kudos
(2) Replies
Evan_Border
Level 8

Thananjeyan.M wrote:
Hi

I want to check the given email address (e.g abc@gmail.com) is correct or wrong in installscript.
Is it Possible in Installscript?


thanks,
Thananjeyan


There is not a super easy way, but see the following thread for a solution that others have used:
h t t p s : / / community.flexerasoftware.com/showthread.php?160858-Problems-calling-VBScript-COM-objects-from-InstallScript&p=358149#post358149
https://community.flexerasoftware.com/showthread.php?160858-Problems-calling-VBScript-COM-objects-from-InstallScript&p=358149#post358149

Here's a little context around that thread: someone else needed to check the validity of an e-mail address, and the eventual solution was to use a regular expression. InstallScript does not use regular expressions, so the thread shows how to work around that.
0 Kudos
rajeev15
Level 3

As Evan metioned, I used the VB Script function in InstallscriptMSI project



prototype BOOL ValidateString(STRING, VARIANT);

function BOOL ValidateString(szString,szPattern)
OBJECT oRegEx;
BOOL MatchFound;
begin

//try to create the RegEx object
try
set oRegEx = CoCreateObject("VBScript.RegExp");
catch
MessageBox("CoCreateObject Failed- "+ Err.Decription, SEVERE);
endcatch;
oRegEx.Pattern = szPattern;
oRegEx.IgnoreCase = 0;
MatchFound = oRegEx.Test(szString);
set oRegEx = NOTHING;
return MatchFound;
end;


Called the function as follows
[CODE]
emailPattern="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?";
svEmail = abc@gmail.com;
if (!ValidateString(svEmail,emailPattern)) then
MessageBox ("Invalid format for an email address.", INFORMATION);
else
MessageBox ("Valid email address.", INFORMATION);
[/CODE]
0 Kudos