Home > Ask the Microsoft Exchange Experts > Bradley Dinerman: Clients and Mobility Questions & Answers > Adding disclaimers to outgoing SMTP messages in Exchange 2003
Ask The Exchange Expert: Questions & Answers
EMAIL THIS

Adding disclaimers to outgoing SMTP messages in Exchange 2003

Bradley Dinerman EXPERT RESPONSE FROM: Bradley Dinerman

Pose a Question
Other Exchange Categories
Meet all Exchange Experts
Become an Expert for this site


Exchange Server tips, tutorials and expert advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


>
QUESTION POSED ON: 24 May 2006
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?

>
EXPERT RESPONSE
VIEW MEMBER FEEDBACK TO THIS ASK THE EXPERT Q&A.

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.
    1. Paste the code in the gray code window into a text file. Name the file EventSinkScript.vbs.
    2. Edit the file that you just created. I recommend using Notepad.
    3. 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:
      1. TextDisclaimer = "Disclaimer: The information in this email is confidential and should not be forwarded."
      2. HTMLDisclaimer = "Disclaimer: The information in this email is confidential and should not be forwarded."
    1. Save and close the file.
    2. 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.

    1. 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.
    2. 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"

    1. 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.
    2. Hit Enter to run the script.
    3. Test the disclaimer by sending an email to an external recipient.

MEMBER FEEDBACK TO THIS ASK THE EXPERT Q&A:

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:

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
"C:\EventSinkScript.vbs"

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?

<SCRIPT LANGUAGE="VBScript">
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
</SCRIPT>

—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
instead
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.

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.

Any assistance would be appreciated.
—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. If there is a bridgehead, disable it.
  2. Add a second virtual SMTP server, call it "Outbound SMTP." Then configure this on a secondary IP address on the server.
  3. Configure the "Default Virtual SMTP Server" to deliver all mail to the "Outbound SMTP."
  4. Then configure the "Outbound SMTP" to accept relay only from the primary IP address that the "Default Virtual SMTP Server" is on.
  5. 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:

  • Tip: How do I add an email disclaimer to all outgoing email?
  • Expert Advice: Add disclaimers and signatures to outgoing Exchange email
  • Expert Advice: Software for disclaimers
  • Expert Advice: How to add a disclaimer to all outgoing email
  • Expert Advice: How do I add an email disclaimer to all outgoing email?
  • Reference Center: SMTP tips and resources
  • Reference Center: Exchange scripts and programming resources

  • Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


    RELATED CONTENT
    SMTP
    Reconfigure an existing Exchange Server user account for a new user
    Improve Exchange 2003 Internet connectivity, mail flow and performance
    Troubleshoot Exchange 2003 email that gets stuck in the SMTP queue
    Perform an SMTP Telnet to test an outgoing Exchange server connection
    A primer on SMTP and ESMTP servers and commands
    How to use SMTP queues to troubleshoot mail flow
    SMTP greylisting problem on Exchange Server 2003 SP2
    How to retrieve email from an SMTP server using POP3
    SMTP 550 relay error when sending large attachments
    Sending email to an Exchange distribution list containing SMTP and EX addresses

    Microsoft Exchange Server 2003
    Repairing damaged OWA virtual directories in Exchange Server 2003
    Configure a mobile device to receive POP3 email from Exchange Server
    Customizing an Outlook Web Access 2003 email signature
    Why Exchange ActiveSync fails with NAT firewalls
    Is it time to upgrade users' Windows Mobile devices?
    Top 10 Microsoft Exchange Server 2003 registry hacks
    Use Performance Monitor to detect Exchange 2003 message queue problems
    How to set up email disclaimers on a single, back-end Exchange server
    How to customize OWA authentication logon in Exchange Server 2003
    Can a deleted transaction log be restored in Exchange Server 2003?
    Microsoft Exchange Server 2003 Research

    Microsoft Exchange Server Scripts and Programming
    EMS add-on tool generates graphical Exchange Server 2007 reports
    A primer on the Exchange Server 2007 Exchange Management Shell
    How to generate HTML reports with the Exchange Management Shell (EMS)
    Use the Exchange Management Shell Set command to block senders
    How to test Exchange Management Shell commands
    Grant or deny permissions to access a user's Exchange 2007 mailbox
    Control query results with Exchange Management Shell's Format command
    How to use Exchange Management Shell's Filter command
    How to use the Exchange Management Shell command syntax
    Fix OWA message size limit issue after Exchange 2007 SP1 upgrade

    RELATED GLOSSARY TERMS
    Terms from Whatis.com − the technology online dictionary
    SMTP  (SearchExchange.com)

    RELATED RESOURCES
    2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
    Search Bitpipe.com for the latest white papers and business webcasts
    Whatis.com, the online computer dictionary



    Search and Browse the Expert Answer Center
    Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
    Browse our Expert Advice

    HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
    About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
    SEARCH 
    TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

    TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




    All Rights Reserved, Copyright 2004 - 2008, TechTarget | Read our Privacy Policy
      TechTarget - The IT Media ROI Experts