Friday, April 26, 2013

How do I send mail using C# or ASP.NET?

Here is the simple code snippet...

System.Net.Mail.Mailemail email = new System.Net.Mail.Mailemail();
email.To.Add("ToAddress@email.com");
email.Subject = "This is the Subject line";
email.From = new System.Net.Mail.MailAddress("FromAddress@email.com");
email.Body = "This is the email body";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("SMTP Host Address");
smtp.Send(email);

Here is the very simple and short code snippet...


System.Web.Mail.SmtpMail.SmtpServer="SMTP Host Address or IP Address";
System.Web.Mail.SmtpMail.Send("from","To","Subject","MessageText");

No comments:

Post a Comment