OpenWindows Advanced User's Guide

7.6 Saving and Retrieving Letters

In addition to sending and receiving letters, you may also want to save and retrieve them for later use. In mailx you can save letters by appending them to regular text files; you can also append letters to special files called folders. Both methods are discussed below.

mailx makes a distinction between saving letters and copying them; saving removes a letter from the mailbox and appends it to a file or folder; copying leaves a letter in the mailbox and appends a copy to a file or folder.

7.6.1 Saving and Copying Letters in Files

To save a letter into a file, the command form at the mailx prompt is:

s number filename

where number is the number of the letter to be saved and filename is the file where you want to save the letter. For example, to save letter 3 into a file called ~/notes/finance, you would type:

& s 3 ~/notes/finance

(Remember that in a path name, the ~ represents your home directory.)

You can also save several letters at once to the same file. For example, to save letters 3, 5, 6, 7, and 8 to ~/notes/finance, you would type:

& s 3 5-8 ~/notes/finance

If the file you specify does not exist, mailx creates it. If the file does exist, mailx appends the letter you are saving to the end of the file.

Saving a file removes it from your mailbox; mailx displays an asterisk (*) next to the header of any letter than has been saved.

To leave the letter in your mailbox while appending it to another file, use the copy command, as follows:

& c 3 ~/notes/finance

7.6.2 Saving and Copying Letters in Folders

You can dispense with typing full pathnames to files if you save or copy letters to mail folders. Folders are special files that are stored in a folder directory.

The advantages to saving or copying letters to folders is that your letters are automatically kept together in the same directory, where they are easily accessible without typing long pathnames.

7.6.2.1 Setting the Folder Directory

To use folders, you must first set up a folder directory. This is a two-step process:

  1. First, make the directory using the mkdir command.

    For example, if you wanted your folder directory to be called Letters, you would first make the directory:

    $ mkdir Letters
    

  2. Second, use a text editor to edit the .mailrc file in your home directory (which contains mailx options) to set the folder directory path.

    Here you need to edit the folder variable to include the full path name of your newly created folder directory. For example:

    set folder=/home/austin/rose/Letters
    

    or, using the C shell shortcut ~ to specify your home directory.

    set folder=~/Letters
    

Now your folder directory is set to receive letters saved in folders. (The change to the .mailrc file will take effect the next time you start mailx.)

7.6.2.2 Designating Folders

You use the same commands to save or copy letters into folders as into files, except that the folder name is preceded by a plus sign (+) instead of a path name. The + tells mailx that the folder is to be kept in the folder directory (Letters).

For example, to save letter 3 to a folder called projects, type:

& s 3 +projects

mailx interprets this command as meaning "save letter 3 into ~/Letters/projects." (If the folder doesn't already exist, mailx will create it.)

Copy the letter into a folder by typing:

& c 3 +projects

7.6.2.3 Sending a Letter Directly to a File or Folder

You can send copies of your letters directly to one of your files or folders. To send a copy to a folder, simply type the folder name in either the Cc: or the Bcc: field. Sending a copy to a file is similar, but you must include the full path name.

7.6.3 Reading Letters in Files and Folders

To read letters saved in a file, use the command form:

mailx -f filename

Using the example above, you would read the file ~/memos/finance by typing:

$ mailx -f ~/memos/finance

You can read letters saved in a folder with a similar command--just use the + instead of a pathname. For example, to read the letters in the folder projects, you would type:

$ mailx -f +projects

This command starts mailx in the file or folder designated. Only headers for the letters in the file or folder are displayed. Select a letter to read by typing its number at the mailx prompt and pressing Return.

You can also work on mail folders within the mailx program. To see a list of your folders, type this at a mailx prompt:

& folders

To switch from your mailbox to a folder, use the command form:

& folder +foldername

To return to your mailbox, type this at a mail prompt:

& %

To return to the previous folder, type:

& #