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



Save in Target Folder Sample Form

This sample Microsoft Outlook journal form demonstrates the code needed to force an Outlook item to save in a particular folder. We have two particular applications in mind: 

You can also adapt the technique to other types of forms, simply by copying the source code from the sample and modifying the target folder path, as described under Setup.

Setup | Usage | Notes | Limitations | More Information


  1. Download the Savefold.zip file (10.8 kb), then unzip it and open JournalMove.oft. Choose Disable Macros when you see the macro prompt.
  2. Click the View Code button to display the form's code.
  3. Under the InitOpts procedure, provide the full path to the target folder where you want to save items using this form, e.g. "Public Folders/All Public Folders/IT Department/IT Task List"  For appointment and journal forms, you can also set whether you want Start date for the item to default to the current date/time. Otherwise, new items may default to the date the form was published.  
  4. Publish the form, probably to the Organization Forms library. 
Back to Top


The user simply runs the form directly using normal form launch methods.  You can also make this form the default for a particular type of form. The fact that the form saves items in a folder other than the default folder for the type of item is transparent to the user.  

Back to Top


The technique that makes this form save in a specific folder is to create a copy of the item using the Copy method, then use the Move method on the copy to put it in the target folder. The original item is discarded. The fact that the item is a copy is recorded in the built-in BillingInformation field. If your application needs to use this field for some other purpose, you must modify the sample forms' code to replace BillingInformation with either the built-in Mileage field or a user-defined field.  

The form's code includes a generic GetMAPIFolder() function that takes the folder path as its argument and returns a MAPIFolder object. Feel free to copy it to other Outlook projects where you need to return folders other than the Outlook default. 

Back to Top


When the user saves the item, the item closes -- even if the user clicks Save, rather than Save and Close. This is because the open item is the original, not the copy that was moved to the target folder, and must be discarded to avoid confusing the user about which is the "real" item. Redisplaying the copy automatically is difficult, if not impossible. At the time the item is copied and moved to the target folder -- i.e. when Write event fires -- there is no way to know whether the user has clicked Save or Save and Close. If your application needs to keep the item open, you might want to handle this by prompting the user to choose whether to redisplay the item. To obtain the moved item, you would use the Find method on the target folder's Items collection.

I have not found any way to save a message item in a public folder at the same time it is being sent, unless you also send it to the public folder's address. 

Back to Top

More Information

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