Examples: SaveFileDialog method

This agent gets a file name through the "Save As" dialog box then writes the Body item of the selected document to a file by that name.

Sub Initialize
  Dim ws As New NotesUIWorkspace
  Dim session As New NotesSession
  Dim db As NotesDatabase
  Dim dc As NotesDocumentCollection
  Dim doc As NotesDocument
  REM Get selected document
  Set db = session.CurrentDatabase
  Set dc = db.UnprocessedDocuments
  Set doc = dc.GetFirstDocument
  If Not(doc Is Nothing) Then
    REM Get filename from user
    filenames = ws.SaveFileDialog( _
    False,"File name",, "c:\work", "Body.txt")
    If Not(Isempty(filenames)) Then
      REM Write Body item to file
      fileNum% = Freefile()
      Open filenames(0) For Output As fileNum%
      Print #fileNum%, doc.GetItemValue("Body")(0)
      Close fileNum%
    End If
  End If
End Sub