Microsoft KB Archive/288098

= SAMPLE: How to Use SMTP Transport Events to Add a Disclaimer to Outgoing SMTP Messages =

PSS ID Number: 288098

Article Last Modified on 4/22/2003

-

The information in this article applies to:


 * Microsoft Exchange 2000 Server
 * Microsoft Visual C++, 32-bit Enterprise Edition 6.0
 * Microsoft Visual C++, 32-bit Professional Edition 6.0
 * Microsoft Visual C++, 32-bit Learning Edition 6.0

-



This article was previously published under Q288098



SUMMARY
The Smtpdisclaimer.exe sample shows how to programmatically add a disclaimer to all outgoing Simple Mail Transfer Protocol (SMTP) messages.



MORE INFORMATION
The following file is available for download from the Microsoft Download Center:

Smtpdisclaimer.exe

Release Date: Apr-12-2002

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file. Notable Files in Smtpdisclaimer.exe
 * AddDisclaimer.cpp is the C++ source file in which the OnSMTPOutCommand method is implemented.
 * Regsink.bat is a batch file that registers the event sink on the SMTP server. This file is located in the Sink Registration subdirectory.
 * Unregsink.bat is a batch file that unregisters the event sink on the SMTP server. This file is located in the Sink Registration subdirectory.
 * Smtpreg.vbs is a script for managing SMTP protocol and transport event sink bindings. This file is located in the Sink Registration subdirectory.

To build, register, and test Smtpdisclaimer.exe, follow these steps:  Before you build the file, complete the following steps:  In Microsoft Visual C++, click Tools, click Options, and then click Directories. Under Include file directories, make sure that you see the \Program Files\Common Files\System\ADO folder.

 To create an SMTP event, you must have the Smtpevent.h, Mailmsg.h, and Seo.h header files. You can generate these files by using Microsoft Interface Definition Language (MIDL) on the Smtpevent.idl, Mailmsg.idl, and Seo.idl files that are located in the Include folder of the Platform Software Development Kit (SDK). To do this, browse to the IDL's folder from a command prompt and type the following:

midl smtpevent.idl

midl mailmsg.idl

midl seo.idl

  Build the project. This produces and registers SMTPDisclaimer.dll in your debug folder. Register your sink with the SMTP virtual server. There are two ways to do this:  Option 1: Run the Regsink.bat file that is included in the Samplesmtpevent.exe file.

</li> Option 2: Use the Smtpreg.vbs file that is located in the \Exchsrvr\SDK\Support\CDO\Scripts folder.

NOTE: You must have the Exchange SDK installed to have this folder.

From a command prompt, browse to the \Exchsrvr\SDK\Support\CDO\Scripts folder and type the following:

cscript smtpreg.vbs /add 1 OnSessionStart SampleDisclaimer SMTPDisclaimer.AddDisclaimer &quot;EHLO&quot;

If this is successful, you receive a success message that is generated by the script. To unregister this event, type the following:

cscript smtpreg.vbs /remove 1 OnSessionStart SampleDisclaimer

For more information about registering events with Smtpreg.vbs, see the &quot;Managing Event Bindings&quot; topic in the Microsoft Developer Network (MSDN). To find this topic, search on &quot;smtpreg.vbs&quot; (without the quotation marks).</li></ul>

</li> To test your sink, send an e-mail message to an SMTP recipient who is external to your organization. The recipient should receive a modified message with the disclaimer added to the end of the message.</li></ol>

Additional query words: Smtpdisclaimer

Keywords: kbfile kbhowto kbSample KB288098

Technology: kbAudDeveloper kbExchange2000Serv kbExchangeSearch kbVC32bitSearch kbVC600 kbVCsearch

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© 2003 Microsoft Corporation. All rights reserved.