I have write an article on mail sending functionality but i didn’t add attachment in it.
You can check it from here
Today I am going to describe how to send attachment in mail using asp.net
see the below code for mail attachment functionality:
MailMessage Msg = new MailMessage(); Attachment attchment = new Attachment(physicalfilepathcomeshere); Msg.Attachments.Add(attchment); Msg.From = new MailAddress("fromemailaddress"); Msg.To.Add("toemailaddress"); Msg.Subject = "Define your subject line"; Msg.Body = "Content of body"; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.Credentials=new System.Net.NetworkCredential("gmailID","gmailpassword"); smtp.EnableSsl = true; smtp.Send(Msg);
you need to provide physical file path in place of “physicalfilepathcomeshere”.
Hope this will help you in sending mail attachment.