Next: , Previous: , Up: Reading Mail   [Contents][Index]


6.2 Viewing Attachments

MH has the ability to display MIME (Multipurpose Internet Mail Extensions) messages which are simply messages with additional body parts or attachments. You can use the MH commands show16 or mhshow17 from the shell to read MIME messages18.

MH-E can handle attachments as well if the Gnus ‘mm-decode’ package is present. If so, the option mh-decode-mime-flag will be on. Otherwise, you’ll see the MIME body parts rather than text or attachments. There isn’t much point in turning off the option mh-decode-mime-flag; however, you can inspect it if it appears that the body parts are not being interpreted correctly or toggle it with the command ; (semicolon; mh-toggle-mh-decode-mime-flag) to view the raw message. This option also controls the display of quoted-printable messages and other graphical widgets. See Viewing.

Attachments in MH-E are indicated by buttons like this:

[1. image/jpeg; foo.jpg]...

To view the contents of the button, use either mouse-1 or mouse-2 on the button or RET (mh-press-button) when the cursor is over the button. This command is a toggle so if you use it again on the same attachment, it is hidden. If Emacs does not know how to display the attachment, then Emacs offers to save the attachment in a file. To move the cursor to the next button, use the command K TAB (mh-next-button). If the end of the buffer is reached then the search wraps over to the start of the buffer. To move the cursor to the previous button, use the command K S-TAB (mh-prev-button). If the beginning of the buffer is reached then the search wraps over to the end of the buffer.

Another way to view the contents of a button is to use the command K v (mh-folder-toggle-mime-part). This command displays (or hides) the attachment associated with the button under the cursor. If the cursor is not located over a button, then the cursor first moves to the next button, wrapping to the beginning of the message if necessary. This command has the advantage over the previous commands of working from the MH-Folder buffer. You can also provide a numeric prefix argument (as in 4 K v) to view the attachment labeled with that number. If Emacs does not know how to display the attachment, then Emacs offers to save the attachment in a file.

If Emacs does not know how to view an attachment, you could save it into a file and then run some program to open it. It is easier, however, to launch the program directly from MH-E with the command K e (mh-display-with-external-viewer). While you’ll most likely use this to view spreadsheets and documents, it is also useful to use your browser to view HTML attachments with higher fidelity than what Emacs can provide. This command displays the attachment associated with the button under the cursor. If the cursor is not located over a button, then the cursor first moves to the next button, wrapping to the beginning of the message if necessary. You can provide a numeric prefix argument (as in 4 K e) to view the attachment labeled with that number. This command tries to provide a reasonable default for the viewer by calling the Emacs function mailcap-mime-info. This function usually reads the file /etc/mailcap.

Use the command K o (mh-folder-save-mime-part) to save attachments (the mnemonic is “output”). This command saves the attachment associated with the button under the cursor. If the cursor is not located over a button, then the cursor first moves to the next button, wrapping to the beginning of the message if necessary. You can also provide a numeric prefix argument (as in 3 K o) to save the attachment labeled with that number. This command prompts you for a filename and suggests a specific name if it is available.

You can save all of the attachments at once with the command K a (mh-mime-save-parts). The attachments are saved in the directory specified by the option mh-mime-save-parts-default-directory unless you use a prefix argument (as in C-u K a) in which case you are prompted for the directory. These directories may be superseded by MH profile components, since this function calls on mhstore (mhn) to do the work.

The default value for the option mh-mime-save-parts-default-directory is ‘Prompt Always’ so that you are always prompted for the directory in which to save the attachments. However, if you usually use the same directory within a session, then you can set this option to ‘Prompt the First Time’ to avoid the prompt each time. you can make this directory permanent by choosing ‘Directory’ and entering the directory’s name.

The sender can request that attachments should be viewed inline so that they do not really appear like an attachment at all to the reader. Most of the time, this is desirable, so by default MH-E suppresses the buttons for inline attachments. On the other hand, you may receive code or HTML which the sender has added to his message as inline attachments so that you can read them in MH-E. In this case, it is useful to see the buttons so that you know you don’t have to cut and paste the code into a file; you can simply save the attachment. If you want to make the buttons visible for inline attachments, you can use the command K t (mh-toggle-mime-buttons) to toggle the visibility of these buttons. You can turn on these buttons permanently by turning on the option mh-display-buttons-for-inline-parts-flag.

MH-E cannot display all attachments inline however. It can display text (including HTML) and images.

Some older mail programs do not insert the needed plumbing19 to tell MH-E whether to display the attachments inline or not. If this is the case, MH-E will display these images inline if they are smaller than the window. However, you might want to allow larger images to be displayed inline. To do this, you can change the options mh-max-inline-image-width and mh-max-inline-image-height from their default value of zero to a large number. The size of your screen is a good choice for these numbers.

Sometimes, a mail program will produce multiple alternatives of an attachment in increasing degree of faithfulness to the original content. By default, only the preferred alternative is displayed. If the option mh-display-buttons-for-alternatives-flag is on, then the preferred part is shown inline and buttons are shown for each of the other alternatives.

Many people prefer to see the ‘text/plain’ alternative rather than the ‘text/html’ alternative. To do this in MH-E, customize the option mm-discouraged-alternatives, and add ‘text/html’. The next best alternative, if any, will be shown.

Occasionally, though, you might want to see the preferred alternative. The command : (mh-show-preferred-alternative) displays the message with the default preferred alternative. This is as if mm-discouraged-alternatives is set to ‘nil’. Use the command RET (mh-show) to show the message normally again.

You can view the raw contents of an attachment with the command K i (mh-folder-inline-mime-part). This command displays (or hides) the contents of the attachment associated with the button under the cursor verbatim. If the cursor is not located over a button, then the cursor first moves to the next button, wrapping to the beginning of the message if necessary. You can also provide a numeric prefix argument (as in 4 K i) to view the attachment labeled with that number.

For additional information on buttons, see the chapters Article Buttons and MIME Commands in the The Gnus Manual.


Footnotes

(16)

See the section Reading Mail: inc show next prev in the MH book.

(17)

See the section Reading MIME Mail in the MH book.

(18)

You can call them directly from Emacs if you’re running the X Window System: type M-! xterm -e mhshow message-number. You can leave out the ‘xterm -e’ if you use mhlist or mhstore.

(19)

This plumbing is the ‘Content-Disposition:’ header field.


Next: , Previous: , Up: Reading Mail   [Contents][Index]