Exchange-Online-PowerShell-Recipes

Append HTML Warning Banner To Messages From External Senders

Problem

You want to add a banner to the end of messages sent from outside your organization.

Solution

Create a transport rule to add a snippet of HTML code to the end of the message body. First, store the HTML in a Here-String1.

$html = @"
<html>
    <body>
        <p style="background-color:orange; border-style:double">
        !! WARNING !! This message is from someone outside your organization.
        Use caution when replying or handling links and attachments.</p>
    </body>
</html>
"@
New-TransportRule -FromScope NotInOrganization -SentToScope InOrganization `
-ApplyHTMLDisclaimerLocation Append -ApplyHTMLDisclaimerText $html -ApplyHTMLDisclaimerFallBackAction Wrap

Discussion

The banner is a small snippet of HTML. How this rule applies the banner to messages can be read from the parameters:

This recipe shows one of many rules this cmdlet can create.

The HTML, styling, and warning message in the $html variable are not special. Change them to suit your needs. The location of the message is flexible. The -ApplyHTMLDisclaimerLocation can be set to:

Again, use the location that works for you.

  1. Here-String