---
title: "Sending Mail in ASP.NET."  
description: "Here in this blog I will tell you that how to send mail to users using SmtpClient and MailMessage class. Here I have created a small function which is"  
author: "Anonymous User"  
published: 2011-05-23  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/186/sending-mail-in-asp-dot-net  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 2 minutes  

---

# Sending Mail in ASP.NET.

Here in this [blog](https://www.mindstick.com/articles/12705/myths-and-misconception-about-blog) I will tell you that how to [send mail](https://www.mindstick.com/articles/1502/how-to-send-mail-in-node-js) to [users](https://www.mindstick.com/news/2244/issue-preventing-users-from-accessing-facebook-s-social-networking-platforms-has-been-resolved) using [SmtpClient](https://www.mindstick.com/interview/34185/how-do-you-send-an-email-using-smtpclient-in-c-sharp) and MailMessage class. Here I have created a small [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) which is used to send mail. One thing important that before using this [method](https://www.mindstick.com/forum/166/webservice-method) [your application](https://www.mindstick.com/forum/34702/please-tell-me-what-is-cross-site-scripting-and-how-is-it-harmful-for-your-application) should be hosted on some webserver.\

```
/// <summary>        /// This method will be used to send mail to client        /// by using Smtp and MailMessage class.        /// </summary>        /// <param name="sFrom"></param>        /// <param name="sTo"></param>        /// <param name="sBcc"></param>        /// <param name="sCC"></param>        /// <param name="sSubject"></param>        /// <param name="sBody"></param>        public static void sendMail(string sFrom, string sTo, string sBcc, string sCC, string sSubject, string sBody)        {            MailMessage message = new MailMessage();          //Here we will create object of MailMessage class.            message.From = new MailAddress(sFrom);       //Initilize From in mail address.            message.To.Add(new MailAddress(sTo));        //Initilize To in mail address.                        if (!string.IsNullOrEmpty(sBcc))           //Check whether sBcc is not empty.            {                message.Bcc.Add(new MailAddress(sBcc));    //Add sBcc in mail address.            }            if (!string.IsNullOrEmpty(sCC))          //Check whether sCC is not empty.            {                message.CC.Add(new MailAddress(sCC));      //Add CC in mail address.            }            message.Subject = sSubject;        //Add subject in mail message.            message.Body = sBody;            //Add body in mail message.            message.IsBodyHtml = true;                          message.Priority = MailPriority.High;   //Set priority of mail message.            SmtpClient client = new SmtpClient();                  //Create an object of Smtp client.            client.Send(message);            //Send message by using send() method.        }
```

---

Original Source: https://www.mindstick.com/blog/186/sending-mail-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
