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.IsValidEmail(FromEmailAddress) AndAlso EmailTemplates.Email.IsValidEmail(CustomerEmail) Then
If String.IsNullOrEmpty(AttachmentType) AndAlso String.IsNullOrEmpty(AttachmentName) AndAlso Attachment Is Nothing Then
'There is no attachements
EmailTemplates.Email.SendMessage(EmailTemplate.EmailBody, CustomerEmail, Nothing, Nothing, EmailTemplate.EmailSubject, FromEmailAddress, EmailRetentionPeriod, SourceSystemId)
Else
EmailTemplates.Email.SendMessage(EmailTemplate.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(email))
{
isEmail = false;
}
else
{
//use IsMatch to validate the address
isEmail = check.IsMatch(email);
}
//return the value to the calling method
return isEmail;
}
}
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.