Check the Valid Email and Invalid Email Address in VB.NET

In this article, we will see how to check the Valid Email and Invalid Email Address in VB.NET.
  • 3430

In this article, we will see how to check the Valid Email and Invalid Email Address in VB.NET.

We will check email address throw the "" web service. We will add "" url in the web service.After that this service add in button click code.

Web.Config:- We will add appsetting in the web configuration. 

appSettings file="ValidEmail_net_webservicex_www_ValidateEmail">
    <add key="net.webservicex.www.ValidateEmail" value=""/>

This code is aspx:-

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <title>Check the ValidEmail Address</title>
    <form id="form1" runat="server">
        <asp:Label ID="lableEmailAddress" runat="server" Text="EmailAddress"></asp:Label>
        <asp:TextBox ID="textbox" runat="server" CausesValidation="True"></asp:TextBox>
        <asp:Button ID="CheckButton" runat="server" Text="CheckButton" OnClick="CheckButton_Click"/>

This code is .VB:-

Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Text
Imports System.Net.Mail
Imports System.Text.RegularExpressions
Imports System.Data.SqlClient

Partial Class _Default
   Inherits System.Web.UI.Page

 Protected Sub CheckButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckButton.Click
        Dim con As New SqlConnection("Data Source=MCNDESKTOP10; Initial Catalog=Data;Uid=sa; pwd=wintellect")
        Dim list_emails As New ArrayList()
        Dim i As Integer = 0
        Dim email As String
        Dim cmd As New SqlCommand("Select EmailIDAddress from EmailAddress", con)
        Dim read_Email As SqlDataReader = cmd.ExecuteReader()
        While read_Email.Read()
            email = read_Email.GetValue(i).ToString()
            Dim cls As net.webservicex.www.ValidateEmail = New net.webservicex.www.ValidateEmail()
            Dim result As Boolean = cls.IsValidEmail(email)
        End While
    End Sub
End Class


More Articles

© 2020 DotNetHeaven. All rights reserved.