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.