/* ------------------------ My Meta Content Here SEO ------------------------ */


Main Menu

Monday, May 13, 2013

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;

                Attachment at = new Attachment(FileUpload1.PostedFile.InputStream, MediaTypeNames.Application.Octet);
                at.ContentDisposition.FileName = this.FileUpload1.FileName;

            if(mm.Attachments.Count > 0)
                //Clear the attachments and delete the sessionid folder from tempFiles

Read More »

Recent Posts

My Blog List