Share via


Copy Method

Copy method as it applies to the View object.

Creates a new instance of a View object.

expression.Copy(Name, SaveOption)

*expression   * Required. An expression that returns one of the above objects.

Name   Required String. Represents the name of the new View object.

OlViewSaveOption

OlViewSaveOption can be one of these OlViewSaveOption constants.
olViewSaveOptionAllFoldersOfType
olViewSaveOptionThisFolderEveryone
olViewSaveOptionThisFolderOnlyMe

Copy method as it applies to the AppointmentItem, ContactItem, DistListItem, DocumentItem, JournalItem, MailItem, MeetingItem, NoteItem   , PostItem, RemoteItem, ReportItem, TaskItem, TaskRequestAcceptItem, TaskRequestDeclineItem, TaskRequestItem, and TaskRequestUpdateItem objects.

Creates another instance of an object.

expression.Copy

*expression   * Required. An expression that returns one of the above objects.

Example

As it applies to the View object.

The following Microsoft Visual Basic/Visual Basic for Applications (VBA) example creates a copy of a view called "New Table View" and saves it in the current folder. To run this example, you need to first create a view called 'New Table View' programmatically or by using the Microsoft Outlook user interface.

Sub CopyView()
'Copies a view

    Dim olApp As Outlook.Application
    Dim objViews As Outlook.Views
    Dim objNewView As Outlook.View

    Set olApp = New Outlook.Application
    Set objViews = _
    olApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Views
    'Create copy of View object
    Set objNewView = objViews("New Table View").Copy(Name:="Table View Copy", _
    SaveOption:=olViewSaveOptionThisFolderEveryone)

End Sub

As it applies to the AppointmentItem, ContactItem, DistListItem, DocumentItem, JournalItem, MailItem, MeetingItem, NoteItem   , PostItem, RemoteItem, ReportItem, TaskItem, TaskRequestAcceptItem, TaskRequestDeclineItem, TaskRequestItem, and TaskRequestUpdateItem objects.

This Visual Basic for Applications example creates an e-mail message, sets the Subject to "Speeches", uses the Copy method to copy it, then moves the copy into a newly created e-mail folder named "Saved Mail" within the Inbox folder.

Sub CopyItem()
    Dim myolApp As New Outlook.Application
    Dim myNameSpace As Outlook.NameSpace
    Dim myFolder As Outlook.MAPIFolder
    Dim myNewFolder As Outlook.MAPIFolder
    Dim myItem As Outlook.MailItem
    Dim myCopiedItem As Outlook.MailItem
    Set myolApp = CreateObject("Outlook.Application")
    Set myNameSpace = myolApp.GetNamespace("MAPI")
    Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
    Set myNewFolder = myFolder.Folders.Add("Saved Mail", olFolderDrafts)
    Set myItem = myolApp.CreateItem(olMailItem)
    myItem.Subject = "Speeches"
    Set myCopiedItem = myItem.Copy
    myCopiedItem.Move myNewFolder
End Sub

If you use Microsoft Visual Basic Scripting Edition (VBScript) in an 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 myFolder = myNamespace.GetDefaultFolder(6)
Set myNewFolder = myFolder.Folders.Add("Saved Mail", 16)
Set myItem = Application.CreateItem(0)
myItem.Subject = "Speeches"
Set myCopiedItem = myItem.Copy
myCopiedItem.Move myNewFolder

Applies to | AppointmentItem Object | ContactItem Object | DistListItem Object | DocumentItem Object | JournalItem Object | MailItem Object | MeetingItem Object | NoteItem Object | PostItem Object | RemoteItem Object | ReportItem Object | TaskItem Object | TaskRequestAcceptItem Object | TaskRequestDeclineItem Object | TaskRequestItem Object | TaskRequestUpdateItem Object | View Object