try this
string TextMessage = "some message";
string ApplicationDate = DateTime.Now.ToString("dd_MMM_yyyy");
StringBuilder sb = new StringBuilder();
sb.AppendLine("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
sb.AppendLine("<head id=\"Head1\" runat=\"server\" >");
sb.AppendLine("<title></title>");
sb.AppendLine("</head>");
sb.AppendLine("<body>");
sb.AppendLine("<form id=\"form2\" runat=\"server\">");
sb.AppendLine("<div>");
sb.AppendLine(TextMessage);
sb.AppendLine("<div>");
sb.AppendLine("</form>");
sb.AppendLine("</body>");
sb.AppendLine("</html>");
String filename = String.Concat(ApplicationDate, ".html");
string path = Server.MapPath("ChatFiles");
path = path + "\\" +ApplicationDate;
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
File.WriteAllText(path + @"\" + filename, sb.ToString());