Brinkster Knowledge Base

KB Home   /  Support  /  Code Snippets  /  Email  /   How do I send an email with ASP.NET 2.0
How do I send an email with ASP.NET 2.0 Articles
To send email via your ASP.Net pages, you can mimic the following code samples.

Special Note
Be sure to make the following changes when using these coding examples:
1. Replace you@domain.com with a valid Brinkster hosted email account.
2. Replace password with the password for the email account used above.
3. Replace user@domain.com with a valid email account.

**Your FROM address must be the same as the email address you authenticate with.**


System.Net.Mail.MailMessage


<%@ Page Language="VB" %>
<html>
<head runat="server">
</head>
<body>
<%
        Dim NetMail As New Net.Mail.MailMessage()
        Dim MailClient As New Net.Mail.SmtpClient()

        Try
            NetMail.From = New Net.Mail.MailAddress("you@domain.com")
            NetMail.To.Add(New Net.Mail.MailAddress("user@domain.com"))
            NetMail.IsBodyHtml = True
            NetMail.Subject = "Test message sent using the System.Net.Mail component"
            NetMail.Body = "This is the body of the message."
        
            MailClient.Host = "mymail.brinkster.com"
            MailClient.Port = 25
            MailClient.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
            MailClient.UseDefaultCredentials = False
            MailClient.Credentials = New Net.NetworkCredential("
you@domain.com", "password")

            MailClient.Send(NetMail)
        Catch ex As Exception
            Response.Write(ex.Message)
        Finally
            NetMail.Dispose()
            NetMail = Nothing
            MailClient = Nothing
        End Try
%>
</body>
</html>