ASP.net
ASP / ASP.Net / Vignette
ASP / ASP.Net / Oracle
Books RSS Feed for ASPMatrix.com Book Reviews
 
 
Partner Sites
www.learnasp.com
 
ASPFriends.com

www.411asp.net

www.wwwcoder.com
   
 
ASP.net > Send Mail Message Tutorial
 
.net Namespace: System.Web.Mail.MailMessage
 

This tutorial will show how to send an email using the MailMessage Class in ASP.net. This is actually very simple to do, and requires no 3rd party components. The properties are very easy to understand, and are as follows:

  • Attachments: The list of the attachments that are sent with the message.
  • Bcc: A delimited list (semicolon (;) ) of email addresses.
  • Body: The message body.
  • BodyEncoding: Indicates the body encoding type.
  • BodyFormat: Indicates message body format (HTML or Text).
  • Cc: A delimited list (semicolon (;) ) of email addresses.
  • From: The from email address.
  • Headers: Any custom headers for the message.
  • Priority: The priority of the e-mail message.
  • Subject: The subject line of the message.
  • To: The recipient email address.
  • UrlContentBase: A URL base of all message relative URLs in the email (HTML format).
  • UrlContentLocation:

The below example just shows the basic pieces. In the future we will expand it to include all the properties.

In the meantime, help us let Brent know he is a REDNECK! Click the button to send him an email!

'---- Instantiate MailMessage -------------
Dim myEmail As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage

'---- Set Message Properties -------------
myEmail.From = "webmaster@redneck.com"
myEmail.To = "Brent-Is-A-Redneck@redneck.com"
myEmail.Cc = "MrRedneck@redneck.com"
myEmail.Bcc = "MyNameIsMudd@redneck.com"
myEmail.Subject = "Guess who's a REDNECK!"
myEmail.BodyFormat = System.Web.Mail.MailFormat.Text
myEmail.Body = "This is to let you know that Brent is a REDNECK!"

'---- Send Message -------------------------
System.Web.Mail.SmtpMail.SmtpServer = "enter-mail-server-name-or-IP"
System.Web.Mail.SmtpMail.Send(myEmail)

 
       
      Please report all site problems to: webmaster@aspmatrix.com