Portal
Language
 
Home>Knowledge Base>Programming>ASP.Net>Sending E-mails From ASP.Net
Information
Article ID99
Created On3/19/2009
Modified10/13/2009
Share With Others
Sending E-mails From ASP.Net
Sending E-mails from ASP.Net

Step 1: Place the following in your web.config file, making sure to replace the username and password fields with a valid inbox created from within the control panel:

<configuration>
  <appSettings/>
    <system.net>
      <mailSettings>
        <smtp from="validaddress@yourdomain.com">
          <network host="mail.reliablesite.net" port="25" password="password" userName="validaddress@yourdomain.com" defaultCredentials="false" />
        </smtp>
      </mailSettings>
    </system.net>
  </appSettings>
</configuration>


Step 2: From within the page, use the code below replacing the from, to, subject, and body fields:

Dim mm As New MailMessage()
mm.From = New MailAddress("Fromanyone@somedomain.com", "John Doe")
mm.To.Add(New MailAddress("FirstRecipient@recipientdomain.com"))
mm.To.Add(New MailAddress("SecondRecipient@seconddomain.com"))
mm.Subject = "Subject line"
mm.Body = "This is the message...it can include html tags for formatting"
mm.IsBodyHtml = True
Dim smtp As New SmtpClient
smtp.Send(mm)