ランタイムHTMLテーブルを作成し、メールで送信しています。表はメールの本文に追加されます。ただし、メールがトリガーされると、テーブルの内容ではなくSystem.Web.UI.HtmlControls.HtmlTableが表示されます。
// .csPage:
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[i].Cells[0].Text;
tr.Cells.Add(tc);
HtmlTableCell tc1 = new HtmlTableCell();
tc1.InnerText = dvNumbers.Rows[i].Cells[1].Text;
tr.Cells.Add(tc1);
tbl.Rows.Add(tr);
}
objMail.MobileDeactivationMail(txtMailTo.Text, txtMailCC.Text, txtMailBCC.Text, tbl);
//メールコード:
public bool MobileDeactivationMail(string strReceiverMailId, string CC, string BCC, HtmlTable tbl)
{
bool blnIsMailSent = false;
MailMessage objMailMsg;
try
{
objMailMsg = new MailMessage();
MailAddress FromAdd = new MailAddress("x@x.com");
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;
}
どこが間違っているのですか?