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

Pages

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;


            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();
            }



Read More »

My Blog List

  • काश - काश मुझे भी पीने की आदत होती,मैं कब का मुर्दा हो गया होता। छुटकारा मिलता आज के आतंकवाद से, किसी संतान भूमि में सो गया होता। मेरा एतबार कौन करेगा, मैंने मुर...
    2 months ago
  • काश - काश मुझे भी पीने की आदत होती,मैं कब का मुर्दा हो गया होता। छुटकारा मिलता आज के आतंकवाद से, किसी शमशान भूमि में सो गया होता। मेरा एतबार कौन करेगा, मैंने मुर...
    2 months ago
  • Kumaon University Nainital B.Ed entrance exam test result 2012 - कुमाऊँ विश्वविधालय, नैनीताल (उत्तराखण्ड)
    10 years ago