Compartilhar via


Armazenar dados em um StorageItem para uma solução

This topic describes how to store private application data in solution storage provided by the Outlook object model.

  1. Determine the folder where you would like to store your application data.

Nota Como o armazenamento de soluções é criado como itens ocultos em uma pasta, você só pode armazenar dados de solução se o provedor de armazenamento der suporte a itens ocultos e o cliente tiver direitos de gravar nessa pasta. 2. Use Folder.GetStorage para obter um objeto StorageItem existente ou um novo objeto StorageItem se ainda não existir.

  1. Use StorageItem.Size to determine if the StorageItem is new. If it is, then use the Add method of StorageItem.UserProperties to create a custom property Order Number.

  2. Set the Order Number property. This assumes that an existing StorageItem already has the custom property Order Number defined.

  3. 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

Suporte e comentários

Tem dúvidas ou quer enviar comentários sobre o VBA para Office ou sobre esta documentação? Confira Suporte e comentários sobre o VBA para Office a fim de obter orientação sobre as maneiras pelas quais você pode receber suporte e fornecer comentários.