This step-by-step article describes how to forward mail
with unresolved recipients to a single mailbox.
In Exchange 2000, you
can configure any Simple Mail Transfer Protocol (SMTP) virtual server to
forward all the mail with unresolved recipients to a single host, but you
cannot have all such mail sent to a single mailbox.
However, to work
around this limitation, you can create an additional SMTP virtual server,
forward all the mail with unresolved recipients to the additional SMTP server,
and then use an event sink on the server that rewrites the recipient
Creating and Configuring the Additional SMTP Virtual Server
To create and configure the additional SMTP virtual server:
- Create an additional SMTP virtual server.For additional information about how
to create an additional SMTP virtual server, click the article number below to
view the article in the Microsoft Knowledge Base:
HOW TO: Create Additional SMTP Virtual Servers in Windows 2000
- Configure the default SMTP virtual server to forward all
the mail with unresolved recipients to the new virtual server:
- In Exchange System Manager, click the default SMTP
- On the Action menu, click Properties.
- Click the Messages tab, and then type the IP address (in square brackets ) in the
Forward all mail with unresolved recipients to host
- Click OK or Apply to save the setting.
The forwarding feature may not work until you apply the latest
Exchange 2000 Server service pack.
For additional information about this issue, click
the article number below to view the article in the Microsoft Knowledge Base:
XFOR: "Forward All Mail with Unresolved Recipients" Feature Does Not Work to All Hosts
additional information about general SMTP virtual server configuration options,
click the article number below to view the article in the Microsoft Knowledge
XCON: How to Configure a SMTP Virtual Server Part 1
Using the New Project Wizard to Create the Microsoft Visual Basic ActiveX DLL
To use the New Project Wizard to create the Microsoft Visual
Basic ActiveX DLL:
- Start Microsoft Visual Basic version 6.0.
- On the File menu, click New Project, click ActiveX DLL, and then click OK.
- On the Project menu, click Project1 Properties. Change the Project Name to Q315631, change the name of the Class module to Rewrite, and then click OK.
- Paste the following code in the module:
Private Sub IEventIsCacheable_IsCacheable()
' Only returns S_OK.
Public Sub ISMTPOnArrival_OnArrival(ByVal iMsg As CDO.Message, EventStatus As CdoEventStatus)
Dim Flds As ADODB.Fields
Dim RecipListFld As ADODB.Field
Dim strRecipList As String
' Get Current Recipient List.
' Because this has come to this second virtual server, this should only be "unresolved" recipients.
Set Flds = iMsg.EnvelopeFields
Set RecipListFld = Flds("http://schemas.microsoft.com/cdo/smtpenvelope/recipientlist")
' Update the recipient list to be the user who you want.
' The recommendation here is to create a mailbox that is called "firstname.lastname@example.org", and then give the appropriate
' user permissions on the mailbox.
RecipListFld.Value = "SMTP:email@example.com;"
' Note that the content of the message does not change. Doing so would require that a determination
' be made about the type of message (plain text, HTML, or TNEF), and then the appropriate action would have to be taken.
' This can be difficult, and potentially problematic if certain fields do not exist.
- Replace the value of the "RecipListFld.Value" string with
the address of the mailbox that you want to forward the e-mail messages
- On the Project menu, click References. Make sure that the following references are checked:
Click OK to close the dialog box.
- Microsoft CDO for Exchange 2000 Library
- Microsoft ActiveX Data Objects 2.5 Library
- Server Extension Objects COM Library
- Save the project.
- On the File menu, click Make Q315631.dll, and then click OK.
- Copy the file Q315631.dll to the Exchange 2000
- Register the file by typing regsvr32
q315631.dll at a command prompt.
Registering the Event Sink on the New SMTP Virtual Server
To register the sink, you need the file Smtpreg.vbs from the
Exchange Software Developers Kit. Open a command prompt window, locate the
\Exchsrvr\SDK\Support\CDO\Scripts folder, and then type (where
is the number of the virtual server where the sink
will be registered):
cscript smtpreg.vbs /add X OnArrival Q315631 Q315631.Rewrite "mail from=*"
Make sure that you receive a message from the script that the
registration was successful.
Testing the Event Sink
To test your sink, start a telnet session to the new SMTP virtual
server instance, and then send a message to an arbitrary SMTP address. The
mailbox that you specified in the program code should receive the test message.
For additional information about how to use
telnet on port 25, click the article number below to view the article in the
Microsoft Knowledge Base:
XFOR: Telnet to Port 25 of IMC to Test IMC Communication
Note that the event may not start for messages that
were sent by a Messaging Application Programming Interface (MAPI) client such
as Microsoft Outlook. Because of this, use telnet to test your sink.
For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
PRB: CDOEX: Cannot Change MAPI Message Contents in a CDO SMTP Event Sink
Unregistering the Event Sink
To unregister the event sink, run the following command at a
command prompt (where X
is the number of the virtual
server where the sink is registered):
cscript smtpreg.vbs /remove X OnArrival Q315631
For additional information about registering events with
Smtpreg.vbs, visit the following Microsoft Web site:
Search for "smtpreg.vbs". If you run Smtpreg.vbs without
parameters, Help is displayed with all the parameters.
Article ID: 315631 - Last Review: October 28, 2006 - Revision: 7.3
- Microsoft Exchange Server 2000 Service Pack 3
- Microsoft Exchange Server 2000 Service Pack 1
- Microsoft Exchange 2000 Server Service Pack 2