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



Thursday, March 7, 2013

ASP.Net, C#, SQL, JQuery, Sharepoint: Error Handling in .Net with Example

ASP.Net, C#, SQL, JQuery, Sharepoint: Error Handling in .Net with Example: Error Handling in .Net with Easy Example and Step by Step guide. What is Exception? An exception is unexpected error or problem. What is Exc...

ASP.Net, C#, SQL, JQuery, Sharepoint: Send Email from Gmail in asp.net 2.0

ASP.Net, C#, SQL, JQuery, Sharepoint: Send Email from Gmail in asp.net 2.0: Simplest Way of Sending Email from Gmail protected void btnSendEmail_Click(object sender, EventArgs e) { //Create Mail Message Object with...

Recent Posts

My Blog List