How to send Email with Attachemnts using Asp.Net and C#.net
Use the following:
//use the following namespaces in the top of the page using System.Net.Mail; using System.Net.Mime; //Use the following code to send the email MailMessage mm = new MailMessage(); mm.To.Add("to Email Address"); mm.From = new MailAddress("from email"); mm.Subject = "Any Subject"; mm.Body = "Body Message herre" SmtpClient ss = new SmtpClient("your smtp server here for example smtp.gmail.com"); ss.EnableSsl = true; if(this.FileUpload1.HasFile) { Attachment at = new Attachment(FileUpload1.PostedFile.InputStream, MediaTypeNames.Application.Octet); at.ContentDisposition.FileName = this.FileUpload1.FileName; mm.Attachments.Add(at); } ss.Send(mm); if(mm.Attachments.Count > 0) { //Clear the attachments and delete the sessionid folder from tempFiles mm.Attachments.Dispose(); }