Topic: Vedit macros for Processing Email files (1 of 1), Read 18 times
Conf: VEDIT Macro Library
From: Ian Binnie
Date: Sunday, March 28, 2004 07:03 AM

In Outlook Express you can select a group of emails and drag them into a directory in Windows Explorer. This creates a series of .eml files with their names being the subject lines of each email. These can be "opened" by double clicking.

This is handy, and lets you search saved email files (I use ZTreeWin for this, and most file management functions).

I get a lot of emails with large attachments, including successive releases of documents which I don't want to keep - the base 64 encoding is not very friendly either, so I wanted a program to delete attachments. (I save attachments separately, so they can be searched. NOTE WinZip 9.0 will also open .eml files and extract attachments.)

I wrote a Vedit macro MIMEtrim.vdm which processes MIME Email files, deleting Applications, Images etc.
This has a number of modes:-
// #103==0 : delete attachments & maximum of MIME code
// #103==1 : delete attachments but leave surrounding MIME code
// #103==2 : do not delete text attachments
// #103==3 : both 1 & 2

NOTES option 1 will result in the attachments still showing in an email client, but at zero size.

Even after trimming attachments .eml files can be difficult to read or search in plain text.

A second Vedit macro MIMEquoted.vdm converts quoted-printable text (including html) to normal text (or html). This can be used in conjunction with or independently of MIMEtrim.vdm.

The resultant may not strictly comply with standards, in particular lines may be too long (see below), but are easily read in an editor and most email clients.

In practice many text messages use the QUOTED-PRINTABLE encoding scheme. Any character that is not a printable or white space ASCII character is represented as an equals sign followed by two hexadecimal digits. Lines that are longer than 76 characters are cut off after the 75th character and the line ends with an equals sign.

RFC 2822 places limits on the number of characters in a line. Each line of characters MUST be no more than 998 characters, and SHOULD be no more than 78 characters, excluding the CRLF.

While developing these macros I made a VEDIT colour syntax highlighting definition for Email

The original .eml files set the time stamp to the send time. Editing them changes this; I use these macros in conjunction with a program EDATIMS by Mark Davis , which scans each file for a valid email DATE: line then restores the file's time stamp to this value.