Remove Method

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.  

Remove method as it applies to the Actions, Attachments, Folders, Items, ItemProperties, Pages, Recipients, and UserProperties objects.

Removes an object from one of the above collections.

expression.Remove(Index)

expression   Required. An expression that returns one of the above collections.

Index  Required Long. The index value of the object within the collection.

Removes an object from the specified list.

expression.Remove(Index)

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

Index  Required Variant. The name or ordinal value of an object within a list.

 

Example

As it applies to the Actions, Attachments, Folders, Items, ItemProperties, Pages, Recipients, and UserProperties objects. 

The following example removes a View object from the Views collection.

  Sub DeleteView()
'Deletes a view from the collection

    Dim olApp As Outlook.Application
    Dim objName As NameSpace
    Dim objViews As Views
    Dim objView As View
    Dim strName As String

    strName = "New Icon View"
    Set olApp = Outlook.Application
    Set objName = olApp.GetNamespace("MAPI")
    Set objViews = objName.GetDefaultFolder(olFolderNotes).Views

    For Each objView In objViews
        If objView.Name = strName Then
            objViews.Remove (strName)
        End If
    Next objView

End Sub