Hi nauna,
Refer below article link to validate email using regular expression and also refer below sample.
HTML
Email :<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
<asp:Button Text="Verify" runat="server" OnClick="Verify" />
Code
C#
protected void Verify(object sender, EventArgs e)
{
if (IsValidEmail(txtEmail.Text))
{
// write send code.
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "CropImage", "alert('Not valid email.');", true);
}
}
bool IsValidEmail(string email)
{
try
{
var addr = new System.Net.Mail.MailAddress(email);
return addr.Address == email;
}
catch
{
return false;
}
}
VB.Net
Protected Sub Verify(ByVal sender As Object, ByVal e As EventArgs)
If IsValidEmail(txtEmail.Text) Then
Else
ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "CropImage", "alert('Not valid email.');", True)
End If
End Sub
Private Function IsValidEmail(ByVal email As String) As Boolean
Try
Dim addr = New System.Net.Mail.MailAddress(email)
Return addr.Address = email
Catch
Return False
End Try
End Function
Screenshot