Menu

Wednesday, March 14, 2007

Send a simple email using smtp?

[ 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)

2 comments:

Genesis said...

So is there a special package or library to import to do this so easily. Likewise there is JavaMail package in Java which i used for my PIA assignment. But not sure how to do this in .NET

La girly said...

you think i could go in or what