Knowledgebase: Downloads
ASP.NET sample send mail code
Posted by Premium Reseller on 06 February 2013 09:32 AM

Download zip file, extract and upload to website home folder, configure smtp account in web.config file.

Extracts of send mail code:

using System.Net.Mail;

......

MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("noreply@yourdomain.com");
mailMessage.To.Add(new MailAddress(txtEmail.Text));

string emailBody = "Test Asp.net Send Mail";
mailMessage.IsBodyHtml = true;
mailMessage.Subject = "Asp.Net Send mail";
mailMessage.Body = emailBody;

SmtpClient smtpClient = new SmtpClient();
smtpClient.Send(mailMessage);
lblInfo.Text = "Email has been sent";



Attachments 
 
 asp.net-sendmail.zip (3.41 KB)
(2 vote(s))
This article was helpful
This article was not helpful