StorageItem.Delete Method (Outlook)

Permanently removes the StorageItem object from the parent folder.

Version Information

Version Added: Outlook 2007

Syntax

expression .Delete

expression A variable that represents a StorageItem object.

Remarks

This call allows a solution to clean up or reset the storage for its private data. Attempting to delete a StorageItem that has been removed by a prior StorageItem.Delete call will result in the error, "Could not complete the deletion."

For more information on deleting solution data stored in a StorageItem object, see Updating and Deleting Solution Storage.

Example

The following code sample in Visual Basic for Applications shows how to clean up any existing StorageItem object that has the specified subject, create a new instance with the same subject, assign a value to a custom property, and save the new instance.

Sub AssignStorageData() 
 
 Dim oInbox As Outlook.Folder 
 
 Dim myStorage As Outlook.StorageItem 
 
 
 
 Set oInbox = Application.Session.GetDefaultFolder(olFolderInbox) 
 
 ' Remove and reset any existing instance of StorageItem of the specified subject 
 
 Set myStorage = oInbox.GetStorage("My Private Storage", olIdentifyBySubject) 
 
 myStorage.Delete 
 
 Set myStorage = Nothing 
 
 ' Get a new instance of StorageItem 
 
 Set myStorage = oInbox.GetStorage("My Private Storage", olIdentifyBySubject) 
 
 myStorage.UserProperties.Add "Order Number", olNumber 
 
 myStorage.UserProperties("Order Number").Value = 1000 
 
 myStorage.Save 
 
End Sub

See Also

Concepts

StorageItem Object Members

StorageItem Object