Outlook 2000 VBA Programmers Reference
The CopyTo method takes the currently referenced MAPIFolder and makes a copy of it and its contents in the specified destination MAPIFolder.
|DestinationFolderObject||MAPIFolder||Required, the Folder object that you wish to hold the copy in|
Dim onMAPI As NameSpace Dim ofStart As MAPIFolder Dim ofDestination As MAPIFolder Set onMAPI = Application.GetNamespace("MAPI") Set ofStart = onMAPI.GetDefaultFolder(olFolderInbox) Set ofDestination = onMAPI.GetDefaultFolder(olFolderOutbox) ofStart.CopyTo ofDestination
In this example we are creating a copy of the Inbox folder in the Outbox folder. If there is already a folder called Inbox here then the method will add a sequence number to the end of the new object. The CopyTo method is likely to be used to create back-ups of important folders.
The Delete method provides a way to remove a MAPIFolder object. It will delete this MAPIFolder object from its parent Folders collection.
This method works in the same way as the delete option on the GUI. However, if the folder is located within the Deleted Items folder, there is no warning massage or option to cancel the delete.
The Display method displays a new Explorer for the MAPIFolder with the current object as the active MAPIFolder. An Explorer is an Outlook window that shows the contents of a folder. So if you already have an Outlook window open for the user, this method will open a new Outlook window in front of the user with the contents of the specified MAPIFolder visible. It will not make any changes to the old Explorer. The Explorer object is fully covered in chapter 7.
Dim onMAPI As NameSpace Dim ofFolder As MAPIFolder Set onMAPI = Application.GetNamespace("MAPI") Set ofFolder = onMAPI.GetDefaultFolder(olFolderInbox) ofFolder.Display
In the above example the ofFolder variable is set to the default Inbox folder. Then a new Explorer object is opened with this MAPIFolder object as the active folder.
The GetExplorer method returns an invisible Explorer object that has the specified MAPIFolder object as its active folder. Once you have this Explorer object you can use the Activate method of the Explorer object to show it.
|DisplayMode||Long||Optional, one of the OlFolderDisplayMode constants. If omitted olFolderDisplayNormal is use by default.|
The result of using each of the OlFolderDisplayMode constants is shown below.
OlFolderDisplayFolderOnly (1) displays, next to the Folder name, a drop-down list of folders available. All navigation buttons are also available. Notice the figure below has all navigation buttons on the toolbar.
olFolderDisplayNoNavigation (2) displays the current MAPIFolder and the user is unable to navigate to any other MAPIFolder object. Notice that the navigational buttons on the toolbar are invisible.
olFolderDisplayNormal (0) displays the Explorer just as it appears when you open Outlook.
Dim onMAPI As NameSpace Dim ofFolder As MAPIFolder Dim oeExplorer As explorer Set onMAPI = Application.GetNamespace("MAPI") Set ofFolder = onMAPI.GetDefaultFolder(olFolderDrafts) Set oeExplorer = ofFolder.GetExplorer(olFolderDisplayNoNavigation) oeExplorer.Activate
This code was used to show the second Explorer object in the set of three above, displaying the default Drafts folder with no folder navigation available. The Activate method of the Explorer object is used to show the MAPIFolder to the user. Note that the optional display mode parameter only comes into play when the Explorer object methods are used to show it and not the Display method of the MAPIFolder.
The MoveTo method moves a MAPIFolder to a specified MAPIFolder object.
|DestinationFolderObject||MAPIFolder||Required, the destination Folder object that you wish to move the FolderObject to.|
Page 5 of 6