Update 方法

       

Update 方法将对 AddressEntry 对象所做的更改发布到邮件系统中。

expression.Update(MakePermanent, Refresh)

expression  必选。该表达式返回 AddressEntry 对象。

MakePermanent  可选,Variant 类型。True 值表明刷新属性缓存,并将所有更改提交到根本的通讯簿中。False 值表明刷新属性缓存,但不提交到永久存储区。默认值为 True

Refresh  可选,Variant 类型。True 值表明从根本的通讯簿中重新加载属性缓存。False 值表明不重新加载属性缓存。默认值为 False

说明

只有在调用了 Update 方法,并且将其 MakePermanent 参数设置为 True 时,新条目或对现有条目的更改才保存在集合中。

若要刷新缓存然后从通讯簿重新加载值,请调用 Update 方法,并且将 MakePermanent 参数设置为 False,将 Refresh 参数设置为 True

示例

本 Visual Basic for Applications 示例使用 Add 方法将新的 AddressEntry 对象添加到“个人通讯簿”中。Name 的值“John Q. Public”对于避免错误是必要的。

如果该条目已经存在,代码将跳转到 DialogBox:Details 方法将显示包含该条目详细信息的对话框。

    Set myOlApp = CreateObject("Outlook.Application")
    Set myNamespace = myOlApp.GetNamespace("MAPI")
    Set myAddrList = myNamespace.AddressLists("Personal Address Book")
    Set myAddrEntries = myAddrList.AddressEntries
    Set myEntry = myAddrEntries.Add("Microsoft Mail Address")
    myEntry.Name = "John Q. Public"
    On Error GoTo DialogBox
    myEntry.Address = "someone@microsoft.com"
    myEntry.Update
    DialogBox:
    myEntry.Details