Blueprism - 突出显示电子邮件正文中的收藏栏

我有一份工作将集合传递到电子邮件正文中。我想突出显示第一列。目前我的代码正在转换第一行。我怎样才能改变这个?


System.Text.StringBuilder sb = new System.Text.StringBuilder);

if(InData.Rows.Count > 0)

{

sb.Append("Hi There,<br><br>");

sb.Append("Please find the below mentioned Information. <br><br>");

sb.Append("<table style='border:1px solid black; border-collapse: collapse;'>");

sb.Append("<tr style='border:1px solid black; border-collapse: collapse; padding:2px;'>");

foreach (System.Data.DataColumn dc in InData.Columns)

{

   sb.Append("<th style='border:1px solid black; border-collapse: collapse; padding:2px;'>");

   sb.Append(dc.ColumnName);

   sb.Append("</th>");

}

sb.Append("</tr>");


int rowNumber = 1;

foreach (System.Data.DataRow dr in InData.Rows)

{

    if (rowNumber == 1)

    {

   sb.Append("<tr style='border:1px solid black; border-collapse: collapse; padding:2px; background-color:yellow;'>");

    }

    else

    {

        sb.Append("<tr style='border:1px solid black; border-collapse: collapse; padding:2px;'>");

    }


  foreach (System.Data.DataColumn dc in InData.Columns)

   {

      sb.Append("<td style='border:1px solid black; border-collapse: collapse; padding:2px;'>");

      sb.Append(dr[dc.ColumnName].ToString());

      sb.Append("</td>");

   }

   sb.Append("</tr>");

   rowNumber ++;

}

sb.Append("</table><br><br>");

sb.Append("Regards,<br>");

sb.Append("Team QueryBot");

}

outEmailHtmlTable = sb.ToString();


阿波罗的战车
浏览 162回答 1
1回答

UYOU

该行的背景颜色突出显示。理想情况下,它应该用于列。在下面的代码中,我删除background-color:yellow;了该行并将其添加到列中,该列将为每行的第一列突出显示。System.Text.StringBuilder sb = new System.Text.StringBuilder;if(InData.Rows.Count > 0){sb.Append("Hi There,<br><br>");sb.Append("Please find the below mentioned Information. <br><br>");sb.Append("<table style='border:1px solid black; border-collapse: collapse;'>");sb.Append("<tr style='border:1px solid black; border-collapse: collapse; padding:2px;'>");foreach (System.Data.DataColumn dc in InData.Columns){&nbsp; &nbsp;sb.Append("<th style='border:1px solid black; border-collapse: collapse; padding:2px;'>");&nbsp; &nbsp;sb.Append(dc.ColumnName);&nbsp; &nbsp;sb.Append("</th>");}sb.Append("</tr>");int rowNumber = 1;foreach (System.Data.DataRow dr in InData.Rows){&nbsp; &nbsp;sb.Append("<tr style='border:1px solid black; border-collapse: collapse; padding:2px;'>");int colNumber=1;&nbsp; foreach (System.Data.DataColumn dc in InData.Columns)&nbsp; &nbsp;{if(colNumber==1){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append("<td style='border:1px solid black; border-collapse: collapse; padding:2px;background-color:yellow;'>");}else{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append("<td style='border:1px solid black; border-collapse: collapse; padding:2px;'>");}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append("<td style='border:1px solid black; border-collapse: collapse; padding:2px;'>");&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append(dr[dc.ColumnName].ToString());&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append("</td>");colNumber++;&nbsp; &nbsp; &nbsp; &nbsp;}&nbsp; &nbsp; &nbsp; &nbsp;sb.Append("</tr>");&nbsp; &nbsp; &nbsp; &nbsp;rowNumber ++;&nbsp; &nbsp; }&nbsp; &nbsp; sb.Append("</table><br><br>");&nbsp; &nbsp; sb.Append("Regards,<br>");&nbsp; &nbsp; sb.Append("Team QueryBot");&nbsp; &nbsp; }&nbsp; &nbsp; outEmailHtmlTable = sb.ToString();希望这能解决您的问题。下面是我用来验证的一段代码供您参考。&nbsp;private void button1_Click(object sender, EventArgs e)&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; System.Text.StringBuilder sb = new System.Text.StringBuilder();&nbsp; &nbsp; &nbsp; &nbsp; sb.Append("Hi There,<br><br>");&nbsp; &nbsp; &nbsp; &nbsp; sb.Append("Please find the below mentioned Information. <br><br>");&nbsp; &nbsp; &nbsp; &nbsp; sb.Append("<table style='border:1px solid black; border-collapse: collapse;'>");&nbsp; &nbsp; &nbsp; &nbsp; sb.Append("<tr style='border:1px solid black; border-collapse: collapse; padding:2px;'>");&nbsp; &nbsp; &nbsp; &nbsp; sb.Append("<th style='border:1px solid black; border-collapse: collapse; padding:2px;'>");&nbsp; &nbsp; &nbsp; &nbsp; sb.Append("ID");&nbsp; &nbsp; &nbsp; &nbsp; sb.Append("</th>");&nbsp; &nbsp; &nbsp; &nbsp; sb.Append("<th style='border:1px solid black; border-collapse: collapse; padding:2px;'>");&nbsp; &nbsp; &nbsp; &nbsp; sb.Append("Name");&nbsp; &nbsp; &nbsp; &nbsp; sb.Append("</th>");&nbsp; &nbsp; &nbsp; &nbsp; sb.Append("</tr>");&nbsp; &nbsp; &nbsp; &nbsp; int rowNumber = 1;&nbsp; &nbsp; &nbsp; &nbsp; foreach (Employee dr in Employee.GetEmpList())&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (rowNumber == 1)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append("<tr style='border:1px solid black; border-collapse: collapse; padding:2px;'>");&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append("<tr style='border:1px solid black; border-collapse: collapse; padding:2px;'>");&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int col = 1;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (col == 1)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append("<td style='border:1px solid black; border-collapse: collapse; padding:2px;background-color:yellow;'>");&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append(dr.Id);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append("</td>");&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; col++;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append("<td style='border:1px solid black; border-collapse: collapse; padding:2px;'>");&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append(dr.Name);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append("</td>");&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append("</tr>");&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rowNumber++;&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; sb.Append("</table><br><br>");&nbsp; &nbsp; &nbsp; &nbsp; sb.Append("Regards,<br>");&nbsp; &nbsp; &nbsp; &nbsp; sb.Append("Team QueryBot");&nbsp; &nbsp; &nbsp; &nbsp; string stoutEmailHtmlTable = sb.ToString();&nbsp; &nbsp; }}class Employee{&nbsp; &nbsp; public int Id { get; set; }&nbsp; &nbsp; public string Name { get; set; }&nbsp; &nbsp; public static List<Employee> GetEmpList()&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; List<Employee> emp = new List<Employee>();&nbsp; &nbsp; &nbsp; &nbsp; emp.Add(new Employee() { Id = 1, Name = "Venkatesh" });&nbsp; &nbsp; &nbsp; &nbsp; emp.Add(new Employee() { Id = 2, Name = "Ramesh" });&nbsp; &nbsp; &nbsp; &nbsp; return emp;&nbsp; &nbsp; }}Hi There,<br><br>Please find the below mentioned Information. <br><br><table style='border:1px solid black; border-collapse: collapse;'><tr style='border:1px solid black; border-collapse: collapse; padding:2px;'><th style='border:1px solid black; border-collapse: collapse; padding:2px;'>ID</th><th style='border:1px solid black; border-collapse: collapse; padding:2px;'>Name</th></tr><tr style='border:1px solid black; border-collapse: collapse; padding:2px;'><td style='border:1px solid black; border-collapse: collapse; padding:2px;background-color:yellow;'>1</td><td style='border:1px solid black; border-collapse: collapse; padding:2px;'>Venkatesh</td></tr><tr style='border:1px solid black; border-collapse: collapse; padding:2px;'><td style='border:1px solid black; border-collapse: collapse; padding:2px;background-color:yellow;'>2</td><td style='border:1px solid black; border-collapse: collapse; padding:2px;'>Ramesh</td></tr></table><br><br>Regards,<br>Team QueryBot
打开App,查看更多内容
随时随地看视频慕课网APP