System.Net.Mail FAQ

Complete FAQ Listing

3.1.1 How do I send a plain text email? Printer Friendly

The following example demonstrates sending a simple plain text email.
[ C# ]
//create the mail message
MailMessage mail = new MailMessage();

//set the addresses
mail.From = new MailAddress("");

//set the content
mail.Subject = "This is an email";
mail.Body = "this is a sample body";

//send the message
SmtpClient smtp = new SmtpClient("");

[ VB.NET ]
 'create the mail message
Dim mail As New MailMessage()

'set the addresses
mail.From = New MailAddress("")

'set the content
mail.Subject = "This is an email"
mail.Body = "this is a sample body"

'send the message
Dim smtp As New SmtpClient("")