ling
ling

Reputation: 185

Dotnet Nlog Mail Target Bold Body Html Text

The mail target is below is what i have currently. I would like to bold the text "Date" and "Calling Class" in the email body. What is the best approach for this? Thanks.

    <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}"/>

Upvotes: 2

Views: 1884

Answers (2)

jlavallet
jlavallet

Reputation: 1375

I'm using NLog version: 4.5.11 with NLog.MailKit version 3.0.0.

This worked for me:

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

Note that I escaped the less than and greater than characters.

Upvotes: 2

t3chb0t
t3chb0t

Reputation: 18685

Try this:

body="Date:<strong>${longdate}</strong>${newline}
      Calling Class: <strong>${callsite}</strong>"

Upvotes: 1

Related Questions