Outlook) (StorageItem.Save 方法

保存 StorageItem

语法

表达式

表达 一个代表 StorageItem 对象的变量。

备注

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.

有关将解决方案数据保存到 StorageItem 对象的详细信息,请参阅创建数据并将数据保存到解决方案存储区

示例

Visual Basic for Applications 在下面的代码示例演示如何使用 StorageItem 对象存储专用解决方案数据。 它将数据保存在收件箱文件夹中的 邮件 对象的自定义属性。 下面介绍的步骤:

  1. 此代码示例调用 Folder.GetStorage 来获得现有 StorageItem 对象具有主题"我的专用存储"收件箱;如果已存在与该主题没有 邮件GetStorage 将创建具有该主题 StorageItem 对象。

  2. 如果新创建的 邮件 ,该代码示例创建对象的自定义属性"订单号"。 请注意,"订单号"收件箱中的隐藏项的属性。

  3. 然后,代码示例将一个值分配给"订单号",并保存 StorageItem 对象。

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

另请参阅

StorageItem 对象

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。