Send Html file as a email body of the mail using C# in ASP.net

jaffreenu
 
on Dec 16, 2016 03:42 AM
9452 Views

 

MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com", 587);
mail.From = new System.Net.Mail.MailAddress(sendFrom);
mail.To.Add(sendTo);
mail.Subject = "Test";
using (StreamReader reader = File.OpenText("D:\\report.html"))
{
  mail.Body = reader.ReadToEnd();
}
mail.IsBodyHtml = true;
//mail.BodyEncoding = Encoding.UTF8;
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential(sendFrom, pwd;
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
MessageBox.Show("Message Sent");

This was my code. And I'm getting partial html file as the body of the mail. I need Complete file as the body of the mail. Kindly Rply.

Thanks

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Dec 16, 2016 03:42 AM