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



2 comments:

  1. The Epson Movie - Mate projector features versatile connectivity, including HDMI support, which have made it
    easy to enjoy, while having more entertainment options. Its a user friendly program
    that everybody can use. I am not talking about composing an entire symphony and playing it back like
    a parroting robot.

    my web-site - MOTU Digital Performer V8.02 free download

    ReplyDelete
  2. This site has some advantages expressed by current users that
    I discuss later. If you are getting an internet business off the ground, or you
    have been in the game for a while, but don't understand why you can't get
    a good response from your clients or prospective clients, than you already know
    that communication is one of the most important currencies
    around when it comes to doing businesses online.
    Word - Press is an open source blog publishing application and can be used for
    basic content management.

    Feel free to surf to my web site ... WP Social Press Review

    ReplyDelete

My Blog List