Add a new post


Name  
Email*  
Subject  
Message
 
 
Protected by Clearscreen.SharpHIPTo prevent abuse from bots, please enter the text you see.:
 

* In order to reduce SPAM, all email addresses will be obfuscated so they cannot be read by spam bots.
For example: 'test@test.com' will become 'test (at) test dot com'.

How do I send a simple email?
The following example demonstrates sending a simple text email.
 
[ C# ]

MailMessage mail = new MailMessage();
mail.To = "me@mycompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
SmtpMail.SmtpServer = "localhost";  //your real server goes here
SmtpMail.Send( mail );

[ VB.NET ]
Dim mail As New MailMessage()
mail.To = "me@mycompany.com"
mail.From = "you@yourcompany.com"
mail.Subject = "this is a test email."
mail.Body = "this is my test email body"
SmtpMail.SmtpServer = "localhost" 'your real server goes here
SmtpMail.Send(mail)