|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
How to: Store Data in a StorageItem for a Solution
This topic describes how to store private application data in solution storage provided by the Outlook object model.
Determine the folder where you would like to store your application data.
Because solution storage is created as hidden items in a folder, you can only store solution data if the store provider supports hidden items and the client has rights to write to that folder.
Set the Order Number property. This assumes that an existing StorageItem already has the custom property Order Number defined.
Use StorageItem.Save to save the StorageItem object as a hidden item in the folder.
Sub StoreData() Dim oInbox As Folder Dim myStorage As StorageItem Dim myPrivateProperty As UserProperty Set oInbox = Application.Session.GetDefaultFolder(olFolderInbox) ' Get an existing instance of StorageItem by subject, or create new if it doesn't exist Set myStorage = oInbox.GetStorage("My Private Storage", olIdentifyBySubject) If myStorage.Size = 0 Then 'There was no existing StorageItem by this subject, so created a new one 'Create a custom property for Order Number Set myPrivateProperty = myStorage.UserProperties.Add("Order Number", olNumber) Else 'Assume that existing storage has the Order Number property already Set myPrivateProperty = myStorage.UserProperties("Order Number") End If myPrivateProperty.Value = lngOrderNumber myStorage.Save End Sub