StorageItem.Delete method (Outlook)
Permanently removes the StorageItem object from the parent folder.
expression A variable that represents a StorageItem object.
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.
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
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.