K Feening
asked on
VB Email Check
Hi
The product I am using has an Email test and I need it to check if an Underscore _ is used in the Customer Address and validate it but it always returns isValidEmail(CustomerEmail ) as False
from the VB.Net Code
If EmailTemplates.Email.IsVal idEmail(Fr omEmailAdd ress) AndAlso EmailTemplates.Email.IsVal idEmail(Cu stomerEmai l) Then
If String.IsNullOrEmpty(Attac hmentType) AndAlso String.IsNullOrEmpty(Attac hmentName) AndAlso Attachment Is Nothing Then
'There is no attachements
EmailTemplates.Email.SendM essage(Ema ilTemplate .EmailBody , CustomerEmail, Nothing, Nothing, EmailTemplate.EmailSubject , FromEmailAddress, EmailRetentionPeriod, SourceSystemId)
Else
EmailTemplates.Email.SendM essage(Ema ilTemplate .EmailBody , CustomerEmail, Nothing, Nothing, EmailTemplate.EmailSubject , FromEmailAddress, EmailRetentionPeriod, SourceSystemId, AttachmentType, AttachmentName, Attachment)
End If
End If
It goes to a section in a File with a .cs extension
public static bool IsValidEmail(string email)
{
bool isEmail = Regex.IsMatch(email, @"\A(?:[a-z0-9!#$%&'*+/=?^ _`{|}~-]+( ?:\.[a-z0- 9!#$%&'*+/ =?^_`{|}~- ]+)*@(?:[a -z0-9](?:[ a-z0-9-]*[ a-z0-9])?\ .)+[a-z0-9 ](?:[a-z0- 9-]*[a-z0- 9])?)\Z", RegexOptions.IgnoreCase);
//make sure an email address was provided
if (string.IsNullOrEmpty(emai l))
{
isEmail = false;
}
else
{
//use IsMatch to validate the address
isEmail = check.IsMatch(email);
}
//return the value to the calling method
return isEmail;
}
}
The product I am using has an Email test and I need it to check if an Underscore _ is used in the Customer Address and validate it but it always returns isValidEmail(CustomerEmail
from the VB.Net Code
If EmailTemplates.Email.IsVal
If String.IsNullOrEmpty(Attac
'There is no attachements
EmailTemplates.Email.SendM
Else
EmailTemplates.Email.SendM
End If
End If
It goes to a section in a File with a .cs extension
public static bool IsValidEmail(string email)
{
bool isEmail = Regex.IsMatch(email, @"\A(?:[a-z0-9!#$%&'*+/=?^
//make sure an email address was provided
if (string.IsNullOrEmpty(emai
{
isEmail = false;
}
else
{
//use IsMatch to validate the address
isEmail = check.IsMatch(email);
}
//return the value to the calling method
return isEmail;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window