aspNetEmail Sample Code

The following code example assumes that you are using the @import directive to reference the component from the GAC.  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.aspnetemail.com/Documentation.aspx

C# Sample

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

<%@ import Namespace="aspNetEmail" %>

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

    void Page_Load(object sender, System.EventArgs e)
    {
 
        EmailMessage msg = new EmailMessage("mail.yourdomain.com");
        msg.FromAddress = "xyz@yourdomain.com";       // Set the to address
        msg.To = "123@yourdomain.com";
        msg.Subject = "Test Email";
        msg.Body = "Hello World!.";
        msg.Send();

        Response.Write("Mail Sent.");
    }

</script>

VB.NET Sample

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

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

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

        Dim msg As EmailMessage = New EmailMessage("mail.yourdomain.com")
        msg.FromAddress = "xyz@yourdomain.com"
        msg.To = "123@yourdomain.com"
        msg.Subject = "Test Email"
        msg.Body = "Hello World."
        msg.Send()

        response.Write("Mail Sent.")

    End Sub

</script>

Add Feedback