C# – How to send a Secure e-mail using SMTP

asp.netcencryptionSecuritysmtp

I am currently using Google Apps to send SMTP e-mails. If my project deploys some of the information that i am going to be sending will be confidential and i would like to make sure the transmission is secure. Can anyone please let me know what i need to do to ensure that i send a safe e-mail using smtp through the google apps smtp server? smtp.google.com.

Any help greatly appreciated.

From what I have been told i need to force Https and have a SSL cert in order to do this. I don't know if this is true?

Best Answer

You Can Use 'smtp.EnableSsl = true' For Enable SSL for security.

MailMessage mail = new MailMessage();
            mail.To.Add("" + to + "");
            mail.From = new MailAddress("" + from + "");
            mail.Subject = "Email using Gmail";
            string Body = "Hi, this mail is to test sending mail" +
                          "";
            mail.Body = Body;
            mail.IsBodyHtml = true;
            Attachment at = new Attachment(Server.MapPath("~/ExcelFile/TestCSV.csv"));
            mail.Attachments.Add(at);
            mail.Priority = MailPriority.High;
            SmtpClient smtp = new SmtpClient();
            smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
            smtp.Credentials = new System.Net.NetworkCredential(""+ username +"", ""+ password +"");
            smtp.EnableSsl = true;
            smtp.Port = 587;
            smtp.Send(mail);