Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在C#project发送的电子邮件中设置不同参数的多种颜色_C#_Html_Asp.net_Email_Colors - Fatal编程技术网

如何在C#project发送的电子邮件中设置不同参数的多种颜色

如何在C#project发送的电子邮件中设置不同参数的多种颜色,c#,html,asp.net,email,colors,C#,Html,Asp.net,Email,Colors,我想设置电子邮件文本的颜色,通过收集不同对象和参数的数据来生成电子邮件。我已经编写了代码,但无法设置每个参数上下文的单独颜色 我的代码是: SmtpClient emailClient = new SmtpClient(); MailMessage emailMessage = new MailMessage(); emailMessage.IsBodyHtml = true; sbEmailBody.Appe

我想设置电子邮件文本的颜色,通过收集不同对象和参数的数据来生成电子邮件。我已经编写了代码,但无法设置每个参数上下文的单独颜色

我的代码是:

SmtpClient emailClient = new SmtpClient();

            MailMessage emailMessage = new MailMessage();
            emailMessage.IsBodyHtml = true;


                sbEmailBody.AppendLine("[" + **test.GetType().Name** + "]");

如何设置test.GetType().Name参数的颜色?

像这样附加html文本

<span style="color:red">My Text"</span>
我的文本”
就像你的例子一样

foreach (ITest test in tests)
{
  sbEmailBody.AppendLine("<span style='color:red'>[" + **test.GetType().Name** + "]</span>");
}
foreach(测试中的测试)
{
sbEmailBody.AppendLine(“[”+**test.GetType().Name**+“]);
}