How to send email with attachments from C#

You can send email from C# using MailMessage class and also send attachments in the email. In this example i have provided one folder and will add all files in that folder as attachments to the email.
You can also check "Send Email using Gmail from C#" and "Send Email by requesting delivery/read receipt from C#"

Please find below C# source code, that shows how to send email with attachments from C# using SMTP server.
I have created sample windows application and added button = btnSendEmailWithAttachment, in this button click event the below code added.

using System;
using System.IO;
using System.Net;
using System.Net.Mail;
using System.Windows.Forms;

namespace SampleWindowsApp
    /// <summary>
    /// Send Email Form 
    /// </summary>
    /// <seealso cref="System.Windows.Forms.Form" />
    public partial class SendEmailForm : Form
        /// <summary>
        /// Initializes a new instance of the <see cref="SendEmailForm"/> class.
        /// </summary>
        public SendEmailForm()

        /// <summary>
        /// Handles the Click event of the btnSendEmailWithAttachment control.
                         /// Author = Himasagar Kutikuppala
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnSendEmailWithAttachment_Click(object sender, EventArgs e)
                //Create the object of MailMessage
                MailMessage mailMessage = new MailMessage();
                mailMessage.From = new MailAddress("", "FromDisplayName"); //From Email Id & Display name
                mailMessage.Subject = "Test Email"; //Subject of Email
                mailMessage.Body = "This is the test email body text"; //body or message of Email
                mailMessage.IsBodyHtml = true;
                mailMessage.Priority = MailPriority.High; //if you want to send High importance email
                //You can add either multiple To,CC,BCC or single emails
                mailMessage.To.Add(new MailAddress(";;;")); //adding multiple TO Email Id
                mailMessage.CC.Add(new MailAddress(";;;")); //Adding Multiple CC email Id
                mailMessage.Bcc.Add(new MailAddress(";;;")); //Adding Multiple BCC email Id

                //Add Attachments, here i gave one folder name, and it will add all files in that folder as attachments, Or if you want only one file also can add
                string attachmentsPath = @"C:\Himasagar";
                if (Directory.Exists(attachmentsPath))
                    string[] files = Directory.GetFiles(attachmentsPath);
                    foreach (string fileName in files)
                        Attachment file = new Attachment(fileName);

                //Assign the SMTP address and port
                SmtpClient smtp = new SmtpClient();
                smtp.Host = "";
                smtp.Port = 25;
                smtp.EnableSsl = false; //If required make it true

                //Network and security related credentials
                NetworkCredential networkCredential = new NetworkCredential ();
                networkCredential.UserName = "user name (email id)";
                networkCredential.Password = "password";
                networkCredential.Domain = "Domain Name";

                smtp.Credentials = networkCredential;

                //Finally send Email
                MessageBox.Show("The email has been sent successfully.");
            catch (Exception ex)

What is GST

GST (Goods and Service Tax) is a comprehensive tax on the supply of goods and services at each stage of any transaction. Read More

Income Tax Information

An income tax is a tax imposed by government on income earned by you. Income tax is a key source of funds that the government uses to fund its activities and serve the public. Read More

General Insurance Companies in India

General insurance is insurance for valuables other than our life and health. General insurance covers the insurer against damage, loss and theft of your valuables. Read More

Types of Bank Loans In India

Loan means lending money from one individual or entity to another. A loan has three components – principal or the borrowed amount, rate of interest and tenure or duration for which the loan is availed. Read More

List of Banks in India

The Reserve Bank of India is the central Bank that is fully owned by the Government of India. It is governed by a central board (headed by a Governor) appointed by the Central Government. Read More

List of Educational Institutions in India

The following list of comprehensive websites on higher education in India. These websites will provide detailed information on education system in India. Read More