Share via


StorageItem.Save Method (Outlook)

Saves the StorageItem.

Version Information

Version Added: Outlook 2007

Syntax

expression .Save

expression A variable that represents a StorageItem object.

Remarks

If the StorageItem has never been saved before, Save saves the item as a hidden item in the Folder on which Folder.GetStorage was called. If the StorageItem has been saved previously and the item has since been changed, Save saves the changes to the item. If the StorageItem has been saved previously and the item has not been changed since then, the Save method does nothing.

For more information on saving solution data to a StorageItem object, see Creating and Saving Data to Solution Storage.

Example

The following code sample in Visual Basic for Applications shows how to use the StorageItem object to store private solution data. It saves the data in a custom property of a StorageItem object in the Inbox folder. The following describes the steps:

  1. The code sample calls Folder.GetStorage to obtain an existing StorageItem object that has the subject "My Private Storage" in the Inbox; if no StorageItem with that subject already exists, GetStorage creates a StorageItem object with that subject.

  2. If the StorageItem is newly created, the code sample creates a custom property "Order Number" for the object. Note that "Order Number" is a property of a hidden item in the Inbox.

  3. The code sample then assigns a value to "Order Number" and saves the StorageItem object.

Sub AssignStorageData() 
 
 Dim oInbox As Outlook.Folder 
 
 Dim myStorage As Outlook.StorageItem 
 
 
 
 Set oInbox = Application.Session.GetDefaultFolder(olFolderInbox) 
 
 ' Get an existing instance of StorageItem, or create new if it doesn't exist 
 
 Set myStorage = oInbox.GetStorage("My Private Storage", olIdentifyBySubject) 
 
 ' If StorageItem is new, add a custom property for Order Number 
 
 If myStorage.Size = 0 Then 
 
 myStorage.UserProperties.Add "Order Number", olNumber 
 
 End If 
 
 ' Assign a value to the custom property 
 
 myStorage.UserProperties("Order Number").Value = 100 
 
 myStorage.Save 
 
End Sub 
 

See Also

Concepts

StorageItem Object Members

StorageItem Object