FILE: A Visual Basic-Based Active Messaging Inbox Agent

ID: Q173915

The information in this article applies to:

SUMMARY

This Inbox Agent executes only when the Microsoft Exchange or Microsoft Outlook client is running and a message that meets its criteria causes it to fire (versus some variations of Visual Basic-based Inbox Agents that are required to run all of the time in order to continuously monitor the Inbox).

The following sample file assumes you are running either the Microsoft Exchange or Microsoft Outlook messaging client, and that the Active Messaging Library version 1.1 or higher is installed and registered on the system and referenced by the Project. For information on where to acquire the Active Messaging Libraries, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q171440
   TITLE     : INFO: Where to Acquire the Collaboration Data Objects
               Libraries

The following file is available for download from the Microsoft Software Library:

 ~ InbxAgnt.exe (size: 51098 bytes) 

For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q119591
   TITLE     : How to Obtain Microsoft Support Files from Online Services

MORE INFORMATION

 Launcher Custom Action and Forward

Description

This sample has two parts.

Launcher.dll is a custom action .dll for your Inbox Assistant. When a message arrives that meets the conditions for your Inbox rule, Launcher launches your VB executable. The executable will be handed the incoming message's ID on the command line. This is makes it possible to develop programs in Visual Basic or another language to perform actions on incoming messages.

Forward.exe, is an example of one of these programs. Forward.exe will forward a message that meets the conditions of an Inbox rule. Forward.exe is a Visual Basic project.

Setup

1. Copy the Launcher.dll and Forward.exe files to a directory on your

   hard disk. A suggested good place to locate it is in a subdirectory
   of your Exchange directory called "Custom Actions." You will
   probably need to create this directory.

2. Your registry must be updated to so the Inbox Assistant can find
   Launcher.dll. Here's how to do this:

      a. Run Regedit (Windows 95) or Regedt32 (Windows NT).
      b. Goto hkey_local_machine\Software\Microsoft\Exchange\Client.
      c. Create a "Custom Actions" key under Client if one doesn't exist.
      d. Create a string value.
      e. Enter value name "Launch."
      f. Enter value data "4.0;PathToTheDLL;1" where path to the .dll
         is the file path to the Launcher.dll; that is,
         C:\Program Files\Microsoft Exchange\Custom Actions\Launcher.dll

3. Launch Exchange or Outlook. Select your Inbox. From the Tools
   menu, select Inbox Assistant, click Add Rule.

4. Create the desired rule condition (for example, the Message is from a
   certain Sender, and so forth).

5. Select the Custom check box. Select the "Launch" action from the
   Custom drop-down list box. If it does not show in the list box, then
   it was not installed properly into your registry. Recheck step 2,
   and double check the physical location of the Launcher.dll file.

6. A dialog box will appear asking you to locate the program to launch.
   Point it to Forward.exe. A suggested location would be another
   custom directory called "Forward" below the "Custom Actions"
   directory you previously created.

7. Test it out. Send a message to yourself that fits the criteria of
   the rule (being careful not to setup a rule that initiates a loop).
   You should see both the original and forwarded message in your Inbox.

More Information on Launcher for Visual C++ Developers

The Launcher is a modified version of the Crarun project that is included in the Exchange Development Kit (EDK). The kit's Crarun.dll launches a program without specifying which message just arrived. This sample takes the .dll one step by further by launching a program and then passing the message ID of the arriving message on the command line. This way, the launching program can access the message object and act on it.

Launcher's Visual C++ source is found in the Launcher directory.

Forward

In this sample, Launcher launches Forward and hands it the MessageId of the incoming message.

Using Active Messaging, Forward logs onto the existing session, then calls the Session.GetMessage method to retrieve the message object. A new message is then created, which it subsequently populates with properties and attributes of the original message (including prepending a comment at the beginning of the body). It then sends the new message onto the recipient specified in the Subject line of the original message.

Forward's Visual Basic source is found in the Forward directory.

Miscellaneous

The Launcher.dll is borrowed from the ExPrint sample found at the following Web site:

   http://www.microsoft.com/technet/resource/downloads/exchange/misc
    /default.htm#c

REFERENCES

For additional information about Collaboration Data Objects versus Active Messaging, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q176916
   TITLE     : INFO: Active Messaging and Collaboration Data Objects (CDO)

Keywords          : kbsample kbActMsg 
Version           : WINDOWS:1.1
Platform          : WINDOWS

Last Reviewed: December 13, 1998