Delete Method

Microsoft Outlook Visual Basic

Delete Method

       

Deletes the object from the collection.

expression.Delete

expression   Required. An expression that returns one of the objects in the Applies To list.

Example

This Visual Basic for Applications example uses the GetFirst method to locate the first folder in the Tasks folder and then uses the Delete method to delete the folder.

Set OlApp = CreateObject("Outlook.Application")
Set olName = OlApp.GetNameSpace("MAPI")
Set olFolder = olName.GetDefaultFolder(olFolderTasks)
Set olOldFolder = olFolder.Folders.GetFirst
olOldFolder.Delete

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 olNameSpace = Application.GetNameSpace("MAPI")
Set olOldFolder = olFolder.Folders.GetFirst olOldFolder.Delete
Set olFolder = myNameSpace.GetDefaultFolder(13)