Brinkster Knowledge Base

KB Home   /  Support  /  Code Snippets  /  Email  /   How do I send an email with ASP.NET 1.1
How do I send an email with ASP.NET 1.1 Articles
To send email via your ASP.Net pages, you can mimic the following code samples. Alternatively, you can go to
http://www.systemwebmail.com/faq/3.8.aspx for some information on using System.Web.Mail.

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

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


VB.Net

<%@ Page language="VB" %>

<%

Dim oMessage As New System.Web.Mail.MailMessage()

 

oMessage.To = "user@domain.com"

oMessage.From = "you@domain.com"

oMessage.Subject = "Test message sent using System.Web.Mail"

oMessage.Body = "This is a test message."

oMessage.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

oMessage.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mymail.brinkster.com"

oMessage.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "you@domain.com"

oMessage.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"

oMessage.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

System.Web.Mail.SmtpMail.SmtpServer = "mail.YourDomain.com"

 

Try

      System.Web.Mail.SmtpMail.Send(oMessage)

      Response.Write("Email sent!")

Catch Ex As Exception

      Response.Write("Unable to send mail!  " & Ex.Message)

End Try

%>



C#

<%@ Page language="C#" %>

<%@ IMPORT namespace="System.Web.Mail" %>

<%

      MailMessage oMessage = new MailMessage();

      oMessage.To = "user@domain.com";

      oMessage.From = "you@domain.com";

      oMessage.Subject = "Test message sent using System.Web.Mail";

      oMessage.Body = "This is a test message.";

      oMessage.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 2;

      oMessage.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"] = "mymail.brinkster.com";

      oMessage.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = "you@domain.com";

      oMessage.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = "password";

      oMessage.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;

      System.Web.Mail.SmtpMail.SmtpServer = "mail.YourDomain.com";

 

      try

      {

            System.Web.Mail.SmtpMail.Send(oMessage);

            Response.Write("Email sent!");

      }

      catch (Exception Ex)

      {

            Response.Write("Unable to send mail! " + Ex.Message);

      }

%>



CDOSYS

<%@ Page language="VB" %>

<%

        Dim CDOSYSMsg As Object

        Dim Config As Object

        Dim Fields As Object

 

        ' Create the objects

        CDOSYSMsg = Server.CreateObject("CDO.Message")

        Config = Server.CreateObject("CDO.Configuration")

        Fields = Config.Fields

 

        With Fields

            .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

            .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mymail.brinkster.com"

            .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "you@domain.com"

            .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"

            .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

            .Update()

        End With

 

        CDOSYSMsg.Configuration = Config

        CDOSYSMsg.To = "user@domain.com"

        CDOSYSMsg.From = "you@domain.com"

        CDOSYSMsg.ReplyTo = "you@domain.com"

        CDOSYSMsg.Subject = "Test message sent using the CDOSYS component"

        CDOSYSMsg.TextBody = "This is a test message."

        CDOSYSMsg.Send()

 

        CDOSYSMsg = Nothing

        Config = Nothing

        Fields = Nothing

%>



ASPEmail

<%@ Page language="VB" %>

<%

Dim MyMail as object

MyMail = Server.CreateObject("Persits.MailSender")

MyMail.Host = "mymail.brinkster.com"

MyMail.body = "This is a test message."

MyMail.IsHTML = True

MyMail.From = "you@domain.com"

MyMail.Username = "you@domain.com"

MyMail.Password = "password"

MyMail.AddAddress ("user@domain.com")

MyMail.Subject = "Test message sent using the ASPEmail component"

 

If MyMail.Send Then

     Response.Write("Message Sent")

Else

     Response.Write("Message Not Sent")

End If

MyMail = Nothing

%>



IPWorks Mail

<%@Page aspcompat=true %>

<%

Dim IPWorks As Object

 

IPWorks = Server.CreateObject("IPWorksASP.Smtp")

IPWorks.MailServer = "mymail.brinkster.com"

IPWorks.MailPort = 25

IPWorks.User = "you@domain.com"

IPWorks.Password = "password"

IPWorks.From = "you@domain.com"

IPWorks.SendTo = "user@domain.com"

IPWorks.Subject = "Test message sent using the IPWorks Mail component"

IPWorks.MessageText = "Testing with a message."

IPWorks.Send()

 

IPWorks = Nothing

%>



JMail

<%@ Page language="VB" %>

<%

Dim JMail as Object

 

JMail = Server.CreateOBject( "JMail.Message" )

       

JMail.MailServerUserName = "you@domain.com"

JMail.MailServerPassword = "password"

JMail.From = "you@domain.com"

JMail.AddRecipient ("user@domain.com")

JMail.Subject = "Test message sent using the JMail component"

JMail.Body = "This is a test message."

       

If  JMail.Send("mymail.brinkster.com" ) Then

Response.Write("Message sent using Dimac JMail.<BR><BR>")

Else

Response.Write("Message not sent using Dimac JMail.<BR><BR>")

End If

 

JMail = Nothing

%>