Delete Method 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 myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderTasks)
Set myOldFolder = myFolder.Folders.GetFirst
myOldFolder.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 myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(13)
Set myOldFolder = myFolder.Folders.GetFirst
myOldFolder.Delete