aspNetMX Sample Code

The following code example assumes that you are using the @import directive to reference the component from the GAC.  You You can avoid this by simply downloading the trial version of the component and placing it in your /bin folder.

Online Documentation for aspNetEmail can be found at: http://www.aspnetmx.com/documentation.aspx


C# Sample

// NOTE: The line below can be excluded if you reference the assembly in your web.config. See Related Articles
<%@ Assembly name="aspNetMX, Version=2.0.2.0, Culture=neutral, PublicKeyToken=bc571e8da1c1f543" %>

<%@ import Namespace="aspNetMX" %>

<Script runat="server" Language="C#">

    void Page_Load(object sender, System.EventArgs e)
    {
 
           MXValidate mx = new MXValidate();

           //lookup the mx records for microsoft.com
           MXServers servers = mx.GetMXServers( "microsoft.com");

           //get an array of the records from the MXServers object
           MXRecord[] records = servers.Records;

           //write out the Preference and Exchange
           for( int i=0;i<records.Length;i++)
           {
                Response.Write("<br>" + records[i].Preference.ToString() + " : " + records[i].Exchange );
           }

    }

</script>

 

VB.NET Sample

// NOTE: The line below can be excluded if you reference the assembly in your web.config. See Related Articles
<%@ Assembly name="aspNetMX, Version=2.0.2.0, Culture=neutral, PublicKeyToken=bc571e8da1c1f543" %>

<%@ import Namespace="aspNetMX" %>

<Script runat="server" Language="VB">

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)

        Dim mx As New MXValidate()

        'lookup the mx records for microsoft.com
        Dim servers As MXServers = mx.GetMXServers("microsoft.com")

        'get an array of the records from the MXServers object
        Dim records As MXRecord() = servers.Records

        'write out the Preference and Exchange
        Dim i As Integer
        For i = 0 To records.Length - 1
            Response.Write("<br>" & records(i).Preference.ToString() & " : " & records(i).Exchange)
        Next i

    End Sub

</script>