Problem solve Get help with specific problems with your technologies, process and projects.

Adding disclaimers to outgoing SMTP messages in Exchange 2003

SearchExchange.com expert Brad Dinerman explains how to add disclaimers to outgoing SMTP messages in Exchange Server 2003.

I need to add a disclaimer to outgoing SMTP messages in Exchange Server 2003, but I'm not a programmer. I saw the...

Microsoft article, "How to add a disclaimer to outgoing SMTP messages in Visual Basic," but it still isn't clear to me. Can you help me? Is there a way to do this without commercial software?

As you've discovered, Exchange Server is not very user-friendly when dealing with global disclaimers. In fact, the steps described in the article will only work if you are sending messages through an SMTP smart host or a front-end Exchange server. (See Microsoft Knowledge Base article 273233 for details.) This means that you cannot use this on a Windows Small Business Server (SBS) or any back-end Exchange server with mailboxes. You must have a separate, front-end Exchange server on which to run this code.

(NOTE: Member Chris S. has provided a solution that enables you to add disclaimers to outgoing SMTP messages on a back-end Exchange 2003 server. Read his workaround in the Members Feedback section at the end of this tip.)

If your environment does not meet those conditions, you may want to reconsider the commercial software option. The cost of the software may offset the mental aggravation that the code may otherwise give you.

If your environment does meet those conditions, however, then you can proceed to create an Exchange 2003 disclaimer as described in Microsoft Knowledge Base 317680, which you referenced in your question. You don't need to be a programmer to create a disclaimer, though it is helpful to be familiar with programming concepts.

That KB article, in summary, describes two general steps that you must take to create the disclaimer:

1. Create and tweak the script.

  • Paste the code in the gray code window into a text file. Name the file EventSinkScript.vbs.
  • Edit the file that you just created. I recommend using Notepad.
  • Modify the lines near the top of the file that start with "TextDisclaimer =" and "HTMLDisclaimer=." You can put any text you want following the equal signs, as long as it is enclosed between the quotes. Since you are not a programmer, avoid using special symbols, including other quotes, which can throw off the syntax of the statement. Here are two very simple examples:
  • TextDisclaimer = "Disclaimer: The information in this email is confidential and should not be forwarded."
  • HTMLDisclaimer = "Disclaimer: The information in this email is confidential and should not be forwarded."
  • Save and close the file.

Note: In the example provided in the Microsoft KB article, the author includes additional items between the quotes, such as vbCrLf and <p>. Both represent a carriage return and line feed putting a blank line in the text. The former is VBScript and the latter is HTML syntax. If you are comfortable using either of these languages, you can make your disclaimer more aesthetic.

2. Make Exchange Server "aware" of your disclaimer by registering an event sink.

  • The smtpreg.vbs file that the KB article references does not actually appear in the Exchange Software Development Kit (SDK) as indicated. However, you can find it here on MSDN. Copy the code and paste it into a text file that you've named smtpreg.vbs.
  • Open a command prompt and navigate the prompt to the location where you put the smtpreg.vbs file. Then paste the following code into command prompt window (don't hit Enter yet):

cscript smtpreg.vbs /add 1 onarrival SMTPScriptingHost CDO.SS_SMTPOnArrivalSink "mail from=*@your-domain-here.com"

cscript smtpreg.vbs /setprop 1 onarrival SMTPScriptingHost Sink ScriptName "C:\EventSinkScript.vbs"

  • Replace your-domain-here.com with your Internet domain, and also modify the path to EventSinkScript.vbs so that it reflects the path to the file that you created in Step 1.
  • Hit Enter to run the script.
  • Test the disclaimer by sending an email to an external recipient.


When I copy the entire line command into one command, it says I have a syntax problem with cscript. Do I have to do each cscript as separate command lines?

It seems to work then just fine, but I get "set property ScriptName to C:EventSinkScript.vbs." I assume from what I've read that this is the "successful" message I'm waiting for, however, I still I do not get my disclaimer to show up in my SMTP outgoing mail.
—Pete M.


The code actually consists of two separate cscript commands. Each one should be on its own line, as you've correctly observed.

Regarding the success or failure of the disclaimer, can you verify that you are running this on a front-end Exchange Server? It will not work if implemented on a back-end system.
—Brad Dinerman, Client Administration expert


When this response was first posted, there was no clear space between the two lines of code. We have fixed this issue, but if you are having trouble with the clarity of the code string, please email us.
—Kimbers Sheppard, Associate Editor


I followed exactly your instructions for adding disclaimers to outgoing SMTP messages in Exchange 2003, however, I keep receiving this message in the command prompt window.

I should mentioned that this is Exchange Server 2003 Standard on a Windows Small Business Server (SBS) 2003 Premium R2 server.

Please advise what I did wrong.
—Lorenz S.


Lorenz, this code will only run on a front-end Exchange server, as described in the first paragraph of the article:

"...the steps described in the article will only work if you are sending messages through a SMTP smart host or a front-end Exchange server."

Windows Small Business Server is a back-end server, so this technique will not work for your situation unless you have a second Exchange server configured as a front-end server on your network.
—Brad Dinerman, Client Administration expert


I'm trying to add a disclaimer to outgoing SMTP messages in Exchange 2003 per your instructions, but I get the following error:

SMTP messages in Exchange 2003 error

What am I doing wrong? Please advise.
—Christo G.


Christo, it appears that you have a typographical error in the code. Note the portion of your first line in the screen shot reads: DCO.SS_SMTPOnArrivalSink

However, this should read: CDO.SS_SMTPOnArrivalSink

Give it another try and let us know if it works or not.
—Brad Dinerman, Client Administration expert


After executing this command:

cscript smtpreg.vbs /setprop 1 onarrival SMTPScriptingHost Sink ScriptName

The following message appears:

Binding Display Name Specified: SMTPScriptingHost
set property ScriptName to C:\EventSinkScript.vbs

The files EventSinkScript.vbs and smtpreg.vbs are located on the c:\ drive.

Please help me as soon as possible. Thanks in advance.
—Ihab H.


Please verify that you are running the cscript command from within the context of the c:\ drive. If the smtpreg.vbs script is located in the root of the c:\ drive, then you should enter it as:

cscript "c:\smtpreg.vbs" /setprop 1 onarrival SMTPScriptingHost Sink ScriptName "C:\EventSinkScript.vbs"

—Brad Dinerman, Client Administration expert


I have added the function and set the HTML and text disclaimer, but I can't see the HTML disclaimer when sending an email in HTML format. The text version works great, but not the HTML. Is there something I am doing wrong?

Sub ISMTPOnArrival_OnArrival(ByVal Msg, EventStatus)
   TextDisclaimer = vbCrLf & "DISCLAIMER: The information contained in this communication is confidential and may be legally privileged. It is intended solely for the use of the individual or entity to whom it is addressed and others authorised to receive it. If you are not t he intended recipient you are hereby notified that any disclosure, copying, distribution or taking action in reliance of the contents of this information is strictly prohibited and may be unlawful. A.M Alberts (Pty) Ltd t/a Progress Milling is neither liable for the proper, complete transmission of the information contained in this communication, any delay in its receipt, or that the mail is virus-free. " & vbCrLf
HTMLDisclaimer = "<p></p><p>DISCLAIMER:<br>Sample Disclaimer added in a VBScript."

If Msg.HTMLBody <> "" Then
'Search for the "</body>" tag and insert our disclaimer before that tag.
pos = InStr(1, Msg.HTMLBody, "</body>", vbTextCompare)
szPartI = Left(Msg.HTMLBody, pos - 1)
szPartII = Right(Msg.HTMLBody, Len(Msg.HTMLBody) - (pos - 1))
Msg.HTMLBody = szPartI + HTMLDisclaimer + szPartII
End If

If Msg.TextBody <> "" Then
Msg.TextBody = Msg.TextBody & vbCrLf & TextDisclaimer & vbCrLf
End If

'Commit the content changes to the transport ADO Stream object.
Msg.DataSource.Save ' Commit the changes into the transport Stream

EventStatus = cdoRunNextSink
End Sub
—Werner W.


I'm not a VBScript expert in regards to the MSG object, but I believe that you should write an If/Then/Else statement instead of what you have. Here's what I'd like you to try:

If Msg.TextBody != "" Then 'This message is text formatted
Msg.TextBody = Msg.TextBody & vbCrLf & TextDisclaimer & vbCrLf
Else 'Use the HTML formatting command
pos = InStr(1, LCase(Msg.HTMLBody), "</body>", vbTextCompare)
szPartI = Left(Msg.HTMLBody, pos-1)
szPartII = Right(Msg.HTMLBody, Len(Msg.HTMLBody) - (pos-1))
Msg.HTMLBody = szPartI + HTMLDisclaimer + szPartII End If

Please also that for the commands below the "Else" line, I forced everything to lower case (LCase) so that we do an apples-to-apples comparison.

I hope that helps you.
—Brad Dinerman, Client Administration expert


Why can't I compile the smtpreg.vbs file? [See image below.] Please help me.

compile the smtpreg.vbs file

Click on image for enlarged view.

—Fit T.


Fit, you mistyped the command. I've attached a screenshot with the offending command. You typed ".add" instead of "/add." That makes all the difference.

Click on image for enlarged view.

—Brad Dinerman, Client Administration expert


I followed the instructions exactly. The scripts ran with what appeared to be complete success, but when I sent an email to an outside recipient (my home account), I didn't get the disclaimer attached to the email. I tried to send email to other accounts (other than my home account) with no success.

I don't understand what you mean by the terminology "front-end Exchange server" and if that could be the problem. I have Exchange Server 2003 installed and operational on its own server hardware. This server is not a domain server. The operating system is Windows Server 2003. The server is behind a firewall and is connected to our internal network.

—Michael G.


An Exchange server can be configured as a front-end server, which is a server without any mailboxes and whose sole function is to provide network-to-Internet communications (for example, OWA).

If you only have a single Exchange server, then it must be a back-end server by definition, and the disclaimer technique will not work.
—Brad Dinerman, Client Administration expert


Actually, this will work on a "back-end" configured Exchange server. What you need to do is the following:

  1. Add a second virtual SMTP server, call it "Outbound SMTP." Then configure this on a secondary IP address on the server.
  2. Configure the "Default Virtual SMTP Server" to deliver all mail to the "Outbound SMTP."
  3. Then configure the "Outbound SMTP" to accept relay only from the primary IP address that the "Default Virtual SMTP Server" is on.
  4. When applying the event sinks, you apply them to instance 2 instead of instance 1 (or whatever instance your Outbound SMTP server actually is).

—Chris S.


Well, I'll be a son of a gun. I found a system to test and your suggestion does work!
—Brad Dinerman, Client Administration expert

Do you have comments on this Ask the Expert Q&A? Let us know.

Related information from SearchExchange.com:


This was last published in May 2006

Dig Deeper on Legacy Exchange Server versions

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.