我有一个查询,其中我想要加粗其中一个datatable
列。怎么做
"Dear " + dtdoc.Rows[i]["ToUser"].ToString() + ", <br /><br /> " +
我想在asp.net
中将 To_User 显示为粗体更新
我的主题部分粗体无效
public void TransferMail()
{
string conString = string.Empty;
try
{
conString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
}
catch (Exception ex)
{
ex.Message.ToString();
}
string strsql = "Select a.Last_To_User,a.disp_through,a.to_user,a.to_department,a.mkey, k.first_name + ' ' + d.last_name TransferFrom, "+
"a.party_name, a.doc_no Inward_No, c.type_desc Doc_Type, a.ref_no, "+
"convert(varchar(25),a.ref_date,103) Ref_date, " +
" a.Inward_amt, "+
" case when a.disp_through ='DP' then d.first_name + ' ' + d.last_name "+
" else b.first_name + ' ' + b.last_name end ToUser "+
" from inward_doc_tracking_hdr a "+
" left join user_mst b on a.To_User = b.mkey "+
"left join user_mst d on a.Last_To_User = d.mkey "+
" left join user_mst k on a.User_Id = k.mkey "+
" inner join type_mst_a c "+
" on a.doc_type = c.master_mkey " +
"and a.mkey = " + Request.QueryString["Inward_Mkey"].ToString() + " ";
DataTable dtdoc = new DataTable();
using (SqlConnection conn = new SqlConnection(conString))
{
conn.Open();
using (SqlDataAdapter dbdata = new SqlDataAdapter(strsql, conn))
{
dbdata.Fill(dtdoc);
}
conn.Close();
}
DataSet ds = new DataSet();
ds.Tables.Add(dtdoc);
ds.Tables[0].TableName = "Transfer Mailer";
if (dtdoc != null && dtdoc.Rows.Count > 0)
{
for (int i = 0; i < dtdoc.Rows.Count; i++)
{
string StrPriBody = "Dear <b>" + dtdoc.Rows[i]["ToUser"].ToString() + "</b>, <br /><br /> " +
"This is to inform you that <b>" + dtdoc.Rows[i]["Inward_No"].ToString() + "</b> has been " +
"transferred to you by <b>" + dtdoc.Rows[i]["TransferFrom"].ToString() + "</b> <br /><br />" +
"Inward No: <b>" + dtdoc.Rows[i]["Inward_No"].ToString() + "</b> <br />" +
"Party: <b>" + dtdoc.Rows[i]["party_name"].ToString() + "</b> <br />" +
"Doc Type: <b>" + dtdoc.Rows[i]["Doc_Type"].ToString() + "</b> <br />" +
"Doc Ref No.: <b>" + dtdoc.Rows[i]["Ref_no"].ToString() + "</b> <br />" +
"Date: <b>" + dtdoc.Rows[i]["ref_date"].ToString() + "</b> <br />" +
"Amount: <b>" + dtdoc.Rows[i]["Inward_amt"].ToString() + "</b> <br /><br /> " +
"Kindly update the same in the system. <br /><br />" +
"<b>THIS IS A SYSTEM GENERATED MAIL. PLEASE DO NOT REPLY.</b>";
MailMessage mail = new MailMessage();
mail.Subject = "Transfer of document <b>" + dtdoc.Rows[i]["Inward_No"].ToString() + " </b> for processing.";
mail.From = new MailAddress("xxxxxxxxxx");
SmtpClient smtp = new SmtpClient();
smtp.Timeout = 1000000;
smtp.Port = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["Port"]);
smtp.UseDefaultCredentials = true;
smtp.Host = System.Configuration.ConfigurationManager.AppSettings["MailHost1"];
smtp.Credentials = new NetworkCredential(mail.From.ToString(), "PS123456");
smtp.EnableSsl = true;
mail.To.Add(new MailAddress("XXXXXXxx"));
mail.IsBodyHtml = true;
mail.Body = StrPriBody;
smtp.Send(mail);
}
}
}
答案 0 :(得分:2)
"Dear <b>" + dtdoc.Rows[i]["ToUser"].ToString() + "</b>, <br /><br /> " +
或
"Dear <strong>" + dtdoc.Rows[i]["ToUser"].ToString() + "</strong>, <br /><br /> " +
作为更新的问题,请设置
mail.IsBodyHtml = true;
发送之前。