AddToFavorites 方法

       

将当前 MAPI 文件夹添加到 Internet Explorer 收藏夹列表。

expression.AddToFavorites(fNoUI, Name)

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

fNoUI  可选,Variant 类型。指出添加该文件夹时不显示标准的用户界面输入框。这要求指定 Name 参数。

Name  可选,Variant 类型。指定收藏夹的名称(如果包含了 fNoUI 参数)。

示例

以下示例将当前文件夹添加到 Internet Explorer“收藏夹”列表中。子例程接受 MAPIFolder 对象和代表“收藏夹”列表中文件夹名称的 String 类型值。子例程使用用户提供的 String 值作为参数执行 AddToFavorites 方法。没有指定参数 fNoUI,这意味着将不显示用户界面。


Sub FaveChange()

    Dim appolApp As Outlook.Application
    Dim nmsName As NameSpace 'the namespace
    Dim fldFolder As MAPIFolder 'the folder
    Dim strName As String 'user created string

    Set appolApp = Outlook.Application
    'Create instance of namespace
    Set nmsName = appolApp.GetNamespace("Mapi")
    Set fldFolder = nmsName.GetDefaultFolder(olFolderInbox)
    'Prompt user for a Favorites list name
    strName = _
        InputBox("Enter the name of the folder as it will appear in the favorites list.")
    Call FaveList(fldFolder, strName)

End Sub

Sub FaveList(ByRef fldFolder As MAPIFolder, ByVal strName As String)
'Add a Folder object to the Favorites list in Internet Explorer

    'Call method with strName as name argument
    fldFolder.AddToFavorites fNoUI:= True, Name:=strName
    'Display a message to the user
    MsgBox "The folder " & fldFolder.Name & _
           " was added to the Internet Explorer favorites list as " & strName & "."

End Sub