Oct 14, 2008

Sending email through asp.net

namespace :

using System.Net.Mail;


{

SmtpClient SMTP = new SmtpClient();
SMTP.Host = "localhost"; //if you have mailserver IP address replace to localhost
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.From = new MailAddress("info@sample.com");
string Toadd = username.Text;//sample@sample.com
message.To.Add(Toadd.ToString());
message.Subject = "Registration successful";
message.Body = "Thankyou for Registration!
Following are your account details,";
message.IsBodyHtml = true;
SMTP.Send(message);

}



ref:http://forums.asp.net/t/1330871.aspx

No comments: