Send email using ASP.Net and C#

Send email programaticaly using C# and ASP.Net. Please check sample code bellow.

System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.To.Add(new System.Net.Mail.MailAddress("" "Receiver Name"));
mail.CC.Add(new System.Net.Mail.MailAddress("" "CC Name"));
mail.From = new System.Net.Mail.MailAddress("", "Sender Name");
mail.Subject = "Email Subject";
mail.Body = "Email Message";
mail.IsBodyHtml = true;

System.Net.Mail.SmtpClient client = new SmtpClient();

Use following settings in web.config file to set SMTP server, user name and password.

        <network host="" userName ="" password =""/>
Subscribe for our monthly newsletter for updated articles and useful code scripts.

Share It

comments powered by Disqus