SaveOption Property

Microsoft Outlook Visual Basic

Show All

SaveOption Property

       

Returns an OlViewSaveOption constant that specifies the folders in which the specified view is available and the read permissions attached to the view. The SaveOption property is set when the View object is created by using the Add method. Read-only.

OlViewSaveOption can be one of these OlViewSaveOption constants.
olViewSaveOptionAllFoldersOfType All folders of this type can use the view.
olViewSaveOptionThisFolderEveryone All users who can access the current folder can use the view. The view is only associated with this folder.
olViewSaveOptionThisFolderOnlyMe The view is only associated with the current folder and only the user can access the view.

expression.SaveOption

expression   Required. An expression that returns a View object.

Example

The following example displays the names of all views that can be accessed by all users in the Notes folder.

Sub DisplayPublicViews()
'Displays the names of all views that are available to
'all users of this folder

    Dim olApp As Outlook.Application
    Dim objName As NameSpace
    Dim objViews As Views
    Dim objView As View
    Dim strSaveOption As String

    Set olApp = Outlook.Application
    Set objName = olApp.GetNamespace("MAPI")
    Set objViews = objName.GetDefaultFolder(olFolderNotes).Views

    For Each objView In objViews
        If objView.SaveOption = olViewSaveOptionThisFolderEveryone Then
            'if list is empty, start list
            If strSaveOption = "" Then
                strSaveOption = "The following views are available" & _
                                " to all users:" & vbCr & vbCr & objView.Name & vbCr
            Else
            'If not empty, add names to list
                strSaveOption = strSaveOption & _
                                objView.Name & vbCr
            End If
        End If
    Next objView
    'If views exist display names
    If strSaveOption <> "" Then
        MsgBox strSaveOption
    End If

End Sub