I am trying to send me email in HTML format.
<appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
<to value="zzz@zzz.com"/>
<from value="do_not_reply@zz.com"/>
<subject value="zzzAdmin Logged Event" />
<smtpHost value="email.zzz.com"/>
<bufferSize value="1"/>
<lossy value="false"/>
<authentication value="Basic" />
I log the error as html formatted text, but the email clients render the HTML as plain text.
How can I tell the SMTPAppender to add an HTML type to the email message so clients will render the message as the HTML that it is.
The built in SmtpAppender does not support this so you will need to roll your own appender.
Since log4net isn't supporting HTML format in the message body so far, I wrote my own appender:
To use this appender in your log4net config, just replace namespace and class name of your standard SmtpAppender definition and add the isBodyHtml option as follows:
The SendEmail method body source is taken from the latest version of the standard log4net's SmtpAppender. I only removed old Framework versions supporting stuff and added this string:
You can get the latest version of the standard log4net's
SmtpAppender
here.UPDATE:
Below is a sample config (inspired with these examples):