Question

I would like to know if there is any easy way to print multiple emails(about 200) so that they continue on as opposed to printing one per page. I have tried with thunderbird and evolution and this does not seem possible. Would concatenating the individual mail files work or are there other unix utilities that could do this? WOuld sed or awk be suited for this?

Was it helpful?

Solution

Why don't you put all the data from the mails in one text file and print that one.

This could be done by something like:

cat *.eml > file.txt

Or print it directly with

cat *.eml | lpr

OTHER TIPS

Perl makes it pretty easy with the Email::Abstract module. Give the following script (maildump) a list of emails to dump out and then pipe it all into lpr...

maildump m1 m2 m3 m4 | lpr

#!/usr/bin/perl

use Email::Abstract;

while ($mfile = shift @ARGV)
{
    open(DATA, "<$mfile") || die "unable to open $mfile";

    my $message = do { local $/; <DATA>; };

    my $email = Email::Abstract->new($message);

    my $subject = $email->get_header("Subject");
    my $from = $email->get_header("From");
    my $date = $email->get_header("Date");
    my $body = $email->get_body;

    print "SUBJECT: $subject\nFROM: $from\nDATE: $date\n\n$body\n\n";
    print "-" x 65, "\n" if $#ARGV > 0;
}

I can say for sure about *n*x, but if it is possible to define a printer which only outputs text, and that will output to a text file, then you could print your batch to that printer and remove the form-feeds from the resulting text file.

I've used a similar technique in Windows: create a new printer using the Generic / Text-Only driver, and specify that output is to a text file. Then print whatever, give the location of the output file to the print dialog and then clean up the result when the printing is done.

If you're wanting to filter emails then I suggest finding where the data is stored and scripting a solution at that level.

On my Windows box, Thunderbird stores my Inbox in a rather large-ish file at

C:\Documents and Settings\Bruce Axtens\Application Data\Thunderbird\Profiles\x5j9chtd.default\Mail\Local Folders\Inbox

I don't know where *n*x stores yours: perhaps in a hidden folder in your root directory. E.g.

/home/josh/.thunderbird

Parsing raw email data is not for the faint hearted (though Wikipedia has a good article on email which would get you started in the right direction.)

For the rest of us (me included), there are lots of scripting resources to do the hack work for you, while you craft your solution. If found this as a good place to start for Perl. Others may be able to suggest libraries for other languages.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top