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.
SaveOption Optional OlViewSaveOption. The save option that defines the permissions of the View object.
OlViewSaveOption can be one of these OlViewSaveOption constants. |
olViewSaveOptionAllFoldersOfType |
olViewSaveOptionThisFolderEveryone |
olViewSaveOptionThisFolderOnlyMe |
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 example creates a copy of a view called "New Table View" and saves it in the current folder.
Sub CopyView()
'Copies a view
Dim olApp As Outlook.Application
Dim objViews As Views
Dim objNewView As View
Set olApp = 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
This Visual Basic for Applications example creates a mail message, sets the Subject to "Speeches", uses the Copy method to copy it, then moves the copy into a newly created mail folder named "Saved Mail" within the Tasks folder.
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
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(6)
Set myNewFolder = myFolder.Folders.Add("Saved Mail", 16)
Set myItem = Application.CreateItem(0)
myItem.Subject = "Speeches"
Set myCopiedItem = myItem.Copy
myCopiedItem.Move myNewFolder