Folder.GetStorage (Outlook)
Gets a StorageItem object on the parent Folder to store data for an Outlook solution.
The GetStorage method obtains a StorageItem on a Folder object using the identifier specified by StorageIdentifier and has the identifier type specified by StorageIdentifierType. The StorageItem is a hidden item in the Folder, which roams with the account and is available online and offline. If you specify the EntryID for the StorageItem by using the olIdentifyByEntryID value for StorageIdentifierType , then the GetStorage method will return the StorageItem with the specified EntryID. If no StorageItem can be found using that EntryID or if the StorageItem does not exist, then the GetStorage method will raise an error. If you specify the message class for the StorageItem by using the olIdentifyByMessageClass value for StorageIdentifierType , then the GetStorage method will return the StorageItem with the specified message class. If there are multiple items with the same message class, then the GetStorage method returns the item with the most recent PR_LAST_MODIFICATION_TIME. If no StorageItem exists with the specified message class, then the GetStorage method creates a new StorageItem with the message class specified by StorageIdentifier. If you specify the Subject of the StorageItem, then the GetStorage method will return the StorageItem with the Subject specified in the GetStorage call. If there are multiple items with the same Subject, then the GetStorage method will return the item with the most recent PR_LAST_MODIFICATION_TIME. If no StorageItem exists with the specified Subject, then the GetStorage method will create a new StorageItem with the Subject specified by StorageIdentifier. GetStorage returns an error if the store type of the folder is not supported. The following stores return an error when GetStorage is called:
GetStorage (StorageIdentifier, StorageIdentifierType)
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
Arguments
The following arguments are required:
StorageIdentifier (String) - An identifier for the StorageItem object; depending on the identifier type, the value can represent an Entry ID, a message class, or a subject.
StorageIdentifierType (OlStorageIdentifierType) - Specifies the type of identifier for the StorageItem object.
Possible return values are olIdentifyByEntryID - Identifies a StorageItem by EntryID, olIdentifyByMessageClass - Identifies a StorageItem by message class, olIdentifyBySubject - Identifies a StorageItem by Subject.