CopyTo Method

Copies the current folder in its entirety to the destination folder. Returns a MAPIFolder object that represents the new copy.


*expression    * Required. An expression that returns a MAPIFolder object (source folder).

DestinationFolder    Required MAPIFolder object (the destination folder for the copied folder).


This Visual Basic for Applications (VBA) example uses the CopyTo method to copy the default Contacts folder to the default Inbox folder.

Sub CopyFolder()
    Dim myOlApp As New Outlook.Application
    Dim myNameSpace As Outlook.NameSpace
    Dim myInboxFolder As Outlook.MAPIFolder
    Dim myContactsFolder As Outlook.MAPIFolder
    Dim myNewFolder As Outlook.MAPIFolder
    Set myNameSpace = myOlApp.GetNamespace("MAPI")
    Set myInboxFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
    Set myContactsFolder = myNameSpace.GetDefaultFolder(olFolderContacts)
    Set myNewFolder = myContactsFolder.CopyTo(myInboxFolder)
End Sub

If you use Microsoft Visual Basic Scripting Edition (VBScript) in a Microsoft Outlook form, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript code.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myInboxFolder = myNameSpace.GetDefaultFolder(6)
Set myCurrentFolder = myNameSpace.GetDefaultFolder(10)
Set myNewFolder = myCurrentFolder.CopyTo(myInboxFolder)

Applies to | MAPIFolder Object