Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

HOW TO: Forward Mail with Unresolved Recipients to a Single Mailbox


View products that this article applies to.

Summary

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 address.

Creating and Configuring the Additional SMTP Virtual Server

To create and configure the additional SMTP virtual server:
  1. 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:
    303707 HOW TO: Create Additional SMTP Virtual Servers in Windows 2000
  2. Configure the default SMTP virtual server to forward all the mail with unresolved recipients to the new virtual server:
    1. In Exchange System Manager, click the default SMTP virtual server.
    2. On the Action menu, click Properties.
    3. Click the Messages tab, and then type the IP address (in square brackets []) in the Forward all mail with unresolved recipients to host box.
    4. 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:
278529 XFOR: "Forward All Mail with Unresolved Recipients" Feature Does Not Work to All Hosts
For additional information about general SMTP virtual server configuration options, click the article number below to view the article in the Microsoft Knowledge Base:
266686 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:
  1. Start Microsoft Visual Basic version 6.0.
  2. On the File menu, click New Project, click ActiveX DLL, and then click OK.
  3. 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.
  4. Paste the following code in the module:
    Option Explicit
    
    Implements IEventIsCacheable
    Implements ISMTPOnArrival
    
    Private Sub IEventIsCacheable_IsCacheable()
      ' Only returns S_OK.
    End Sub
    
    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  "unresolved@domainname.com", and then give the appropriate
      ' user permissions on the mailbox.
      
      RecipListFld.Value = "SMTP:unresolved@domainname.com;"
      Flds.Update
      
      ' 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.
      
    End Sub
    					
  5. Replace the value of the "RecipListFld.Value" string with the address of the mailbox that you want to forward the e-mail messages to.
  6. On the Project menu, click References. Make sure that the following references are checked:

    • Microsoft CDO for Exchange 2000 Library
    • Microsoft ActiveX Data Objects 2.5 Library
    • Server Extension Objects COM Library
    Click OK to close the dialog box.
  7. Save the project.
  8. On the File menu, click Make Q315631.dll, and then click OK.
  9. Copy the file Q315631.dll to the Exchange 2000 server.
  10. 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 X 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:
153119 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:
273233 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.

↑ Back to the top


Keywords: KB315631, kbhowtomaster

↑ Back to the top

Article Info
Article ID : 315631
Revision : 10
Created on : 10/28/2006
Published on : 10/28/2006
Exists online : False
Views : 563