C# How to Send Email By Html

4/1/2014·1 min read

If you would like to use .NET to send Html email, just need to put set your isHtml to true. So following is sample to code to do that.

Sample Code for sending Html Email
 	// put your email address 
 			string  emailReceiver = "" ;
 
 			SmtpClient  mailClient = new  SmtpClient ("localhost" );
 			mailClient.UseDefaultCredentials = true ;
 			mailClient.DeliveryMethod = SmtpDeliveryMethod .PickupDirectoryFromIis;
 
 			MailMessage  message = new  MailMessage ();
 			MailAddress  address = new  MailAddress (emailReceiver);
 			message.From = address;
 			message.To.Add(address);
 			message.Subject = "test email" ;
 			message.SubjectEncoding = Encoding .Unicode;
 			message.BodyEncoding = Encoding .Unicode;
 			StringBuilder  sb = new  StringBuilder ();
 			message.Body = "<h1'color:'>sending email!</h1>" ;
 			// set this to true 
 			message.IsBodyHtml = true ;
 			message.Priority = MailPriority .Normal;
 			mailClient.Send(message);