I have written the below code to send an email wherein the message body is a html page. I don't get any error when i run this code but do not get any mail. I tried putting body as simple message string then i received the email but not as message body as html page. What is going wrong? please help.
protected void btnSend_Click(object sender, EventArgs e)
{
SendHTMLMail();
}
public void SendHTMLMail()
{
//var path = Server.MapPath("~/test/HTMLPage.htm");
StreamReader reader = new StreamReader(Server.MapPath("~/expo_crm/test/HTMLPage.htm"));
string readFile = reader.ReadToEnd();
string myString = "";
myString = readFile;
SmtpClient smtp = new SmtpClient
{
Host = "mail.abc.com", // smtp server address here…
Port = 25,
EnableSsl = false,
DeliveryMethod = SmtpDeliveryMethod.Network,
Credentials = new System.Net.NetworkCredential("[email protected]", "xxxx"),
Timeout = 30000,
};
MailMessage message = new MailMessage("[email protected]", "[email protected]", " html ", myString);
message.IsBodyHtml = true;
smtp.Send(message);
}