---
title: "How To Send Email Using System.Web.Mail"  
description: "Here in this blog I am trying to explain you about sending emails in ASP.NET by using namespace System.Web.Mail.using System.Web.Mail;   try     strin"  
author: "Uttam Misra"  
published: 2010-11-05  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/42/how-to-send-email-using-system-web-mail  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# How To Send Email Using System.Web.Mail

Here in this [blog](https://www.mindstick.com/articles/12705/myths-and-misconception-about-blog) I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to [explain](https://www.mindstick.com/forum/157854/what-is-system-debugging-explain-some-system-debugging-tools-used-in-modern-computer-systems) you about [sending emails](https://answers.mindstick.com/qa/109539/how-to-restore-outlook-no-longer-sending-emails) in

[ASP.NET](https://www.mindstick.com/articles/934/default-folders-available-inside-the-asp-dot-net-application-folder) by using [namespace](https://www.mindstick.com/articles/12552/namespace) System.Web.Mail.

```
using System.Web.Mail; try             {                 string smtpServer = "relay-hosting.secureserver.net";                 string userName = "contact@yourdomain.com";                 int cdoBasic = 1;                 int cdoSendUsingPort = 2;                 MailMessage msg = new MailMessage();                 if (userName.Length > 0)                 {                     msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", smtpServer);                     msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25);                     msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", cdoSendUsingPort);                     msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", cdoBasic);                     //msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", userName);                     // msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);                 }                 msg.To = "contact@yourdomain.com";                 msg.From = "contact@yourdomain.com";                 msg.BodyFormat = MailFormat.Html;                 msg.Subject = txtSubject.Text;                           msg.Body = "Name: " + txtName.Text + "<br /><br />Company: " + txtCompany.Text + "<br /><br />Email: " + txtEmail.Text + "<br />" + txtDetails.Text;                 SmtpMail.SmtpServer = smtpServer;                 SmtpMail.Send(msg);                  msg.To = txtEmail.Text.Trim();                 msg.From = "donotreply@yourdomain.com";                 msg.BodyFormat = MailFormat.Html;                 msg.Subject = txtSubject.Text;                 msg.Body = @"Hi,<br/>                 Thanks for contacting , we will review your information and try to get back to you ASAP.<br/>                 Thanks;                  SmtpMail.SmtpServer = smtpServer;                 SmtpMail.Send(msg);                 ValidationSummary1.Visible = false;                 lblStatus.Visible = true;                 lblStatus.Text = "Message Sent Sucessfully.";              }             catch             {              }
```

---

Original Source: https://www.mindstick.com/blog/42/how-to-send-email-using-system-web-mail

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
