01 July 2008

Send mail in .NET

This is simple code for send to email using C#.
please add your namespace,
using System.Net.Mail;

//create mail object
MailMessage mail = new MailMessage();
mail.From = new System.Net.Mail.MailAddress("email@emailaddress.com");
mail.Subject = "Subject";
mail.Body = "This is Body,"+"\r\n";


//Define your SMTP
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("mail.mail.co.id");
smtp.Send(mail);


"\r\n" this code for new line.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home