This topic has not yet been rated - Rate this topic

MoveTo Method

Office XP

Moves a folder to the specified destination folder.

expression.MoveTo(DestinationFolder)

expression    Required. An expression that returns a MAPIFolder object.

DestinationFolder    Required. An expression that returns a MAPIFolder object. The destination folder for the folder that is being moved.

Example

This Visual Basic for Applications example adds a new folder to the default Contacts folder, and then uses the MoveTo method to move it to the default Inbox folder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderContacts)
Set myNewFolder = myFolder.Folders.Add("My Contacts")
myNewFolder.MoveTo myNameSpace.GetDefaultFolder(olFolderInbox)

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(10)
Set myNewFolder = myFolder.Folders.Add("My Contacts")
myNewFolder.MoveTo myNameSpace.GetDefaultFolder(6)
Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.