C# Dotnet Nlog邮件目标粗体Html文本

C# Dotnet Nlog邮件目标粗体Html文本,c#,.net,logging,nlog,C#,.net,Logging,Nlog,下面是我目前的邮件目标。我想在邮件正文中加粗“Date”和“Calling Class”。最好的方法是什么?谢谢 <target name="gmail" type="Mail" smtpServer="smtp.gmail.com" smtpPort="587" smtpAuthentication="Basic" smtpUsername="xxxxxx" smtpPassword="xxxxxx" from="xxxxxx"

下面是我目前的邮件目标。我想在邮件正文中加粗“Date”和“Calling Class”。最好的方法是什么?谢谢

    <target name="gmail" type="Mail"
    smtpServer="smtp.gmail.com"
    smtpPort="587"
    smtpAuthentication="Basic"
    smtpUsername="xxxxxx"
    smtpPassword="xxxxxx"
    from="xxxxxx"
    to="xxxxxx"
    enableSsl="true"
    html ="true"
    replaceNewlineWithBrTagInHtml ="true"
    subject="Example - ERROR - ${exception:format=Message}"
    body="Date:${longdate}${newline}Calling Class: ${callsite}"/>

试试这个:

body="Date:<strong>${longdate}</strong>${newline}
      Calling Class: <strong>${callsite}</strong>"
body=“日期:${longdate}${newline}
调用类:${callsite}
我正在使用NLog版本:4.5.11和NLog.MailKit版本3.0.0

这对我很有用:

body="Date:&lt;strong&gt;${longdate}&lt;/strong&gt;${newline}
      Calling Class: &lt;strong&gt;${callsite}&lt;/strong&gt;"

请注意,我对小于和大于字符进行了转义。

这很有效,但相当难看。你有没有找到nlog电子邮件的良好示例正文布局?