Partager via


XHeader Sample Application

The XHeader sample shows you how to respond to the OnEndOfHeaders event and read and modify X-headers in messages.

To download this sample, download the Exchange 2010 Transport Agents SDK from the Microsoft Download Center.

Structure of the Sample

The XHeader sample agent consists of a simple Visual Studio .NET 2005 C# project. By default, the files are installed to C:\Program Files\Microsoft\Exchange Server 2010 SDK\Samples\XHeader.

The following are the primary files for the sample:

  • Install.ps1   An Exchange Management Shell script that installs the compiled sample.

  • Uninstall.ps1   An Exchange Management Shell script that uninstalls the compiled sample.

  • XHeader.csproj The Visual Studio C# project file.

  • XHeaderAgent.cs   The C# source code for the sample.

  • XHeaderConfiguration.cs   The C# source code for the sample.

  • Remove.smtp   A text file that contains Simple Mail Transfer Protocol (SMTP) protocol commands and test message content.

  • Reject.smtp   A text file that contains Simple Mail Transfer Protocol (SMTP) protocol commands and test message content.

Executing the Sample

To execute the XHeader sample agent

  1. Open the XHeader sample agent project in Visual Studio .NET 2005.

  2. Attach the Visual Studio .NET 2005 debugger to the EdgeTransport.exe process.

  3. Telnet to port 25 of the computer that is running Exchange Server 2010.

  4. Copy the contents from the Reject.smtp file and paste them into the telnet session. The server should reject the message and disconnect the telnet session.

  5. Telnet to port 25 of the Exchange server.

  6. Copy the contents from the Remove.smtp file and paste them into the telnet session. The server should accept the message and remove from the message the X-RemoveMe header.

Installing the Sample

To install the XHeader sample agent

  1. Edit the install.ps1 script to make sure that the $EXDIR variable is initialized correctly for your system. The value of the $EXDIR variable should be the path of the Exchange Server 2010 installation directory.

  2. Open the Exchange Management Shell and run the install.ps1 script.

  3. Exit the Exchange Management Shell.

Uninstalling the Sample

To uninstall the XHeader sample agent

  1. Edit the uninstall.ps1 script to make sure that the $EXDIR variable is initialized correctly for your system. The value of the $EXDIR variable should be the path of the Exchange Server 2010 installation directory.

  2. Open the Exchange Management Shell and run the uninstall.ps1 script.