Listing MIME Message Parts

[previous] [next] [table of contents] [index]

mhn -list summarizes the contents of MIME messages. The output has five columns: message number, message part number, content-type and subtype, size in octets, and content-description (if any). If you don't give message numbers, mhn lists the current message. For example, here's how to list the current and next messages (message numbers 33 and 34):

% mhn -list cur next
 msg part  type/subtype              size description
  33       multipart/mixed            44K
     1     text/plain                1459 Description of picture
     2     image/x-pbm                40K Picture of front panel
  34       multipart/alternative     2914
     1     multipart/mixed           1688
     1.1   text/enriched              481
     1.2   message/external-body       69 "Louie Louie"
           audio/basic                   
     1.3   message/external-body       67 Cruisers at Park concert
           image/gif                     
     2     text/plain                 817
Message 33 has multipart/mixed content. The total size is approximately 44,000 octets. The first part is text/plain, 1459 octets (us-ascii characters), with a Content-description: of "Description of picture." Part 2 is an image in the nonstandard content subtype x-pbm. (Although x-pbm means that the pbm format isn't an official MIME type registered with the IANA, it's widely used.) The total size of 44k is the sum of the parts, after decoding, plus the other header fields.

Message 34 has the content-type multipart/alternative. This means that either part 1 or part 2 will be shown. Note that mhn doesn't necessarily list the parts of a multipart/alternative message in the same order they appear in the message. It orders the alternatives in descending priority. The MIME specification says that the "simplest" (closest to plain text) part should be first in the body; this lets people without MIME-capable MUAs make some sense of the message.

Message 34 has three subparts: text/enriched, message/external-body (which, if you retrieve it, will have audio/basic content), and another message/external-body part (this one with image/gif content). Notice that the body parts' sizes are small (69 and 67 characters). That's because they're external parts that haven't been retrieved yet.

mhn -list will show you any comments and parameters from the Content-Type: field if you use its -verbose switch. Compare this listing of message 33 to the one above:

% mhn -list -verbose
 msg part  type/subtype              size description
  33       multipart/mixed            44K
     1     text/plain                1459 Description of picture
             (sorry; I wrote this in a hurry)                           
     2     image/x-pbm                40K Picture of front panel
             x-density="75 dpi"
By default, mhn -list decodes each body part before it counts the size. That isn't necessarily the size a body part has in the message. For example, in a message with base64 encoding, each four encoded characters (like LnNu) are decoded to three octets (8-bit bytes). If you add the -norealsize switch, mhn -list will give you the encoded size of body parts. For long messages, -norealsize can save time, too, because mhn doesn't have to decode the parts before it counts their sizes.

[Table of Contents] [Index] [Previous: Reading MIME Messages] [Next: More About scan]


Last change $Date: 1996/06/06 15:11:06 $

This file is from the third edition of the book MH & xmh: Email for Users & Programmers, ISBN 1-56592-093-7, by Jerry Peek. Copyright © 1991, 1992, 1995 by O'Reilly & Associates, Inc. This file is freely-available; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. For more information, see the file copying.htm.

Suggestions are welcome: Jerry Peek <jpeek@jpeek.com>