DocumentationDiscussions
DocumentationDiscussions
Hey! These docs are for version 4.2, which is no longer officially supported. Click here for the latest version, 2023.4!

Formatting HTML Email

Seq can automatically send email when events are logged – this is accomplished using the Email+ app Seq.App.EmailPlus, which you can install directly from NuGet by following the instructions here.

πŸ“˜

Important Note

The first email app written for Seq is called Seq.App.Email. This is now deprecated, but still published so that users of that version can continue receiving updates and bug fixes. The newer app, described here, is Seq.App.EmailPlus.

The Default Template

Once the app is installed and an instance configured, you're all set to send email: the app comes with a simple template out of the box that turns this event:

1963

Into an HTML email like this:

1174

The template will show the details of the event including its timestamp, level, message and properties.

πŸ“˜

For development and testing of email templates, we use the excellent Papercut local email server/viewer.

Linking Back to your Seq Server

The email sent by Seq includes a link back to view the event on the Seq server. This uses the address on which Seq is configured to listen - http://localhost:5341 by default.

To set a different hostname, configure your Seq instance to listen at a specific URL.

Writing Handlebars Templates

If you would like to send email with a different body, you can provide an HTML template using Handlebars syntax.

πŸ“˜

Looking for an example?

The default template itself is published on GitHub for you to read and modify. Mail clients tend to have very patchy support for CSS. Once you've made changes and confirmed them in a browser, you'll need to run the HTML through a CSS inliner before pasting it into Seq.

To include a property like CartSize in the email body, simply include it in double-braces:

<p>A new sale was processed for {{CartSize}} items.</p>

Built-in Properties

In addition to the properties from the event payload, a number of built-in properties provide access to the event's metadata. These are prefixed with a dollar sign and include:

NameDescription
$EventTypeThe type assigned to the event, for example $00COFFEE
$ExceptionThe full text of the exception attached to the event, if any, including stack trace
$IdThe event's id, for example event-1234...abcd
$LevelVerbose, Debug, Warning, Error, or Fatal
$LocalTimestampThe local timestamp attached to the event including timezone offset
$InstanceThe instance name of the Seq server sending the email, if any
$MessageThe rendered message text for the event
$MessageTemplateThe message template for the event
$PropertiesA list of Name/Value pairs describing the event's properties; see below
$ServerUrlThe Seq server's listening URL
$UtcTimestampThe UTC timestamp of the event

Enumerating event properties

To list properties attached to the event, use the Handlebars each construct. Property objects have a name and a value; there's a built-in helper called "pretty" that can format complex objects if necessary.

<ul>
  {{#each $Properties}}
  <li>{{@key}} is {{pretty this}}</li>
  {{/each}}
</u>