AddToFavorites Method

Adds the current MAPI folder to the Microsoft Internet Explorer Favorites list.

Note  The favorites are not accessible from the Microsoft Outlook user interface. However, you can still access them from Internet Explorer.

expression.AddToFavorites(fNoUI, Name)

*expression   * Required. An expression that returns a **MAPIFolder**object.

fNoUI   Optional Variant. Specifies whether the Add Favorite dialog will be displayed. The default value is False, which displays the dialog. Specify True if you do not want to show the dialog to the user.

Name   Optional Variant. Specifies the name of the favorite folder. The default value is the name of the folder.

Example

The following Microsoft Visual Basic/Visual Basic for Applications (VBA) example adds the current folder to the Favorites list in Internet Explorer. The subroutine accepts a **MAPIFolder**object and a String that represents the folder's name in the Favorites list. It executes the AddToFavorites method, using the String value supplied by the user as its argument.

Sub FaveChange()

    Dim appolApp As Outlook.Application
    Dim nmsName As Outlook.NameSpace
    Dim fldFolder As Outlook.MAPIFolder
    Dim strName As String

    Set appolApp = New 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("Type 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

Applies to | MAPIFolder Object

See Also | AddToPFFavorites Method