Email Address Validation using IP*Works .NET
page 1 of 1
Published: 04 Dec 2004
Unedited - Community Contributed
Abstract
IP*Works is now available to ASP.NET developers in a fully-managed .NET component. The component offers the same functionality as the classic ASP component but does not require the component to be installed on the production server.
by Web Team at ORCS Web
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 25319/ 18

IP*Works provides many useful features including network troubleshooting tools like the TraceRoute or Ping utilities. You can also send emails with attachments using the SMTP or FileMailer feature. IP*Works also provides a FTP and TFTP component which is very useful to web developers with web host providers that do not allow anonymous FTP access. For a complete list of all of the features, visit /N Software's website at http://www.nsoftware.com

In this article, I will demonstrate email validation, one of the features IP*Works .NET offers to ASP.NET developers. IP*Works has many advantages over the built-in ASP.NET classes. One limitation of the built-in ASP.NET class is that you can only validate email addresses based on the A record of their domain name. When using just the A Record, I found that an email address that did not have a web address associated with the domain name would fail. IP*Works solves this problem by allowing you to validate against the MX record directly, a more efficient way to deal with this type of validation.

All you need to do to utilize IP*Works is to drop it into your /BIN folder in the root of your web application.

The code below retrieves the MX record for a domain name cached on a DNS server. Start with the HTML to build a simple form to submit an email address:

<body>
<form id="Form1" method="post" runat="server">
  Enter your email address:
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox> <asp:Button id="button1" runat="server" Text="Submit"> </asp:Button>

<asp:Label id="lblvalid" runat="server"></asp:Label> </form> </body>
Now for the code which is written in VB.NET:
(Short explanations of the code follows)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As 
   System.EventArgs)
        Dim MX As New nsoftware.IPWorks.Mx

        MX.Timeout = "20"
        MX.DNSServer = "ns3.orcsweb.com"
        MX.Resolve(TextBox1.Text)

        If MX.MailServer <> "" Then
            lblvalid.Text = MX.MailServer
        Else

            lblvalid.Text = "Email Address is not Valid"
       End If

    End Sub 
The IP*Works component was invoked by declaring MX as new nsoftware.IPWorks.Mx. 

The timeout was set to 20 seconds and uses ORCS Web's DNS server "ns3.orcsweb.com". (You can use any DNS server you want.)

You can jump right to resolving the email address without removing the email username and the "@" symbol by using "MX.Resolve()".

To retrieve the mail record use "MX.MailServer"

This is all you need to validate an email address. How you handle results is up to you. 

About the Product

IP*Works .NET
Download Info

About the Author

Ben Higgins is a member of the ORCS Web, Inc. Webteam - a company that provides managed hosting services for clients who develop and deploy their applications on Microsoft Windows platforms.



User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2017 ASPAlliance.com  |  Page Processed at 2017-05-26 1:37:45 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search