Outlook Developer Home
Outlook Programmer's Library
 
Outlook Technologies
Outlook Forms
Languages
Samples
Other Technologies

 

 

To set the storage folder for an outgoing Outlook message

Lotus Notes can prompt the sender to specify what folder a message should be saved in. In Outlook, you can set the storage folder on the Options dialog. This VBA code reproduces something closer to the Notes behavior by popping up the Select Folder dialog when the user sends the message.

To try this code, paste it into the built-in ThisOutlookSession module in VBA in Outlook 2000 or later. (Press Alt+F11 to open the VBA window.)

Code Sample

 

Notes

This technique does not work on messages created with File | Send commands in Office programs or similar commands in Windows Explorer or other programs. Those commands invoke Simple MAPI, which bypasses Outlook functionality. An alternative approach would be to monitor the Sent Items folder for new items and ask the user to refile the message at that point in its lifetime.

This code demonstrates the use of the Namespace.PickFolder method to pop up the folder list for the user's selection. Note that you must handle the situation where the user cancels the dialog, in which case PickFolder returns Nothing.

The folder must be in your default information store -- Exchange mailbox or PST file. The IsInDefaultStore() function tests for this. If you need to move items to a different folder, the solution would be to use the ItemAdd event on the Sent Items folder's Items collection. See To quarantine application file attachments for an example of using ItemAdd.

If you want the user to pick a folder only when the item is sent through a specific account, you will need to structure the code as a procedure that Rules Wizard can run, rather than as an Application-level event handler. You can call the SetSaveFolder code below from a "run a script" action on an Outlook 2002 or Outlook 2003 rule. The condition on the rule should be "through specified account."

Another variation would be to not save the item at all if the user doesn't choose a folder. You can do that by setting the DeleteAfterSubmit property to True.

To avoid a macro warning prompt when you start Outlook, follow the instructions for changing the macro security level and signing your code in the article How to Prevent the VBA Macro Security Warning in Microsoft Outlook 2000.

More Information

More samples for the Application.ItemSend event:

Also see:

   
2002-7 TurtleFlock, LLC
All right reserved.
About OutlookCode.com

Send comments to webmaster@outlookcode.com

Designed and Implemented by TerraLink USA 

FrontPage Integration
by RobsonDesignWorks

 
 
get Sue's code | forums | share your own code | registration