HTML Table not working in Mail

ouchmouni

New Member
I am creating a runtime HTML table and sending via mail. The table is added in the body of mail. But when the mail is triggered it is showing System.Web.UI.HtmlControls.HtmlTable instead of the contents of the table.// .csPage:\[code\]HtmlTable tbl = new HtmlTable(); tbl.Border = 1; tbl.CellSpacing = 0; HtmlTableRow trHeader = new HtmlTableRow(); HtmlTableCell tcHeader = new HtmlTableCell(); tcHeader.InnerText = "Mobile Number"; HtmlTableCell tc1Header = new HtmlTableCell(); tc1Header.InnerText = "Carrier"; trHeader.Cells.Add(tcHeader); trHeader.Cells.Add(tc1Header); tbl.Rows.Add(trHeader); for (int i = 0; i < dvNumbers.Rows.Count; i++) { HtmlTableRow tr = new HtmlTableRow(); HtmlTableCell tc = new HtmlTableCell(); tc.InnerText = dvNumbers.Rows.Cells[0].Text; tr.Cells.Add(tc); HtmlTableCell tc1 = new HtmlTableCell(); tc1.InnerText = dvNumbers.Rows.Cells[1].Text; tr.Cells.Add(tc1); tbl.Rows.Add(tr); } objMail.MobileDeactivationMail(txtMailTo.Text, txtMailCC.Text, txtMailBCC.Text, tbl);\[/code\]// Mail Code:\[code\]public bool MobileDeactivationMail(string strReceiverMailId, string CC, string BCC, HtmlTable tbl) { bool blnIsMailSent = false; MailMessage objMailMsg; try { objMailMsg = new MailMessage(); MailAddress FromAdd = new MailAddress("[email protected]"); objMailMsg.From = FromAdd; objMailMsg.To.Add(new MailAddress(strReceiverMailId)); if (CC != "") objMailMsg.CC.Add(new MailAddress(CC)); if (BCC != "") objMailMsg.Bcc.Add(new MailAddress(BCC)); objMailMsg.Subject = "Deactivation of Mobile Numbers"; objMailMsg.Priority = MailPriority.High; objMailMsg.IsBodyHtml = true; objMailMsg.Body = "<table style='font-family:Tahoma; font-size:small';><tr><td> Dear Sir/Mam</td<</tr>," + "<tr><td></td></tr><tr><td></td><td><td><td> Kindly Deactivate the following mobile numbers.</br></br>" + tbl + " </td></td></td></tr></table><table style='font-family:Tahoma; font-size:small';><tr><td>Regards,</td></tr><tr><td>HR</td></tr></table>"; SmtpClient SmtpMail = new SmtpClient(); SmtpMail.Port = 25; SmtpMail.Host = "xxxxx"; System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("xxxxxxx", "xxxxx"); SmtpMail.UseDefaultCredentials = false; SmtpMail.Credentials = SMTPUserInfo; SmtpMail.Send(objMailMsg); objMailMsg.Dispose(); blnIsMailSent = true; } catch (Exception Ex) { blnIsMailSent = false; } return blnIsMailSent; }\[/code\]Where i am going wrong?
 
Back
Top