MHonArc Resources: ARCHIVE

# ARCHIVE

## Syntax

Envariable

  `M2H_ARCHIVE=` [ `0` | `1` ]

Element

  N/A

Command-line Option(s)

  `-archive`
  `-noarchive`

## Description

MHonArc using the ARCHIVE resource to determine if it should create archive data after reading message data.

## Default Setting

    1

## Resource Variables

N/A

## Examples

The purpose of MHonArc is to create HTML archive, so why would you want to disable archiving? One potential purpose is to use MHonArc as a general MIME processing filter to extract all attachments in a mail folder to separate files. To do this, you can define a resource file as follows:

    <MIMEFilters override>
    application/*;m2h_external::filter;mhexternal.pl
    audio/*;m2h_external::filter;mhexternal.pl
    image/*;m2h_external::filter;mhexternal.pl
    model/*;m2h_external::filter;mhexternal.pl
    message/*;m2h_external::filter;mhexternal.pl
    text/*;m2h_external::filter;mhexternal.pl
    video/*;m2h_external::filter;mhexternal.pl
    </MIMEFilters>
    <MIMEArgs override>
    m2h_external::filter; usename
    </MIMEArgs>

For this example, let's assume this resource file is called `.mha-attach.rc` and it exists in your home directory.

NOTE | You notice that we set the "usename" option to the external file filter. Our intent is to be able to save attachments with the filename specified in the message. If you do not want this, you can remove the MIMEARGS resource setting. This will cause the attachments to be saved to a unique filename with an extenstion based upon sub-type is generated.

Now, you can create a shell alias (assuming Csh syntax) as follows:

    alias save-attachments 'mhonarc -noarchive -rcfile ~/mha-attach.rc \!*'

So, if you want to extract all attachments to a mail folder called "inbox" with all attachments saved to `~/tmp`, you would enter the following at your shell prompt (`%`):

        % save-attachments -outdir ~/tmp inbox

Extraction of all attachments from a mail folder maybe more than you need. You may want to just do a single message. Although the following example has nothing to with the ARCHIVE resource, it is related to using MHonArc as a MIME processing tool.

To processing a single message, we can use the same resource file listed above. The difference is how we invoke MHonArc. If you have the message in a file, you can do the following:

        % mhonarc -rcfile ~/mha-attach.rc -single message.822 > /dev/null

Where `message.822` is the file containing a single message. The redirection of standard output to `/dev/null` is done to discard the HTML message text data since all we care about are the attachments saved.

I use MH, and the version I have does not support filenames defined for attachments. Hence, I have the following (Csh) alias in my `.cshrc` file to store all parts of a message to disk utilizing the filenames defined in the message:

    alias store     'show -noshowproc -noheader \!* | \\
                    mhonarc -rcfile ~/dotfile/.mhonarc.attach.rc -single  \\
                    > /dev/null'

The resource file `~/dotfile/.mhonarc.attach.rc` is the same as `mha-attach.rc` in the previous examples.

If you have a MUA that does not support MIME, or the support is minimal, you can use MHonArc as shown to decode and save attachments.

## Version

2.1.2

## See Also