Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Beginning of body extract code' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Beginning of body extract code
Authored by: wfolta on Sep 02, '02 03:37:51PM

(I'll try without doubled backslashes to see what I get...)

If you modify mailbox2.pl, you can get the body text:

#!/usr/bin/perl
$mail_dir = $ARGV[0] ;

$date = "???" ;
$subject = "???" ;
$from = "???" ;

while (<STDIN>)
{
last if (/^$/) ;

if (/^Date: (.+)/)
{ chomp ($date = $1) ; }

if (/^Subject: (.+)/)
{ chomp ($subject = $1) ; }

if (/^From: (.+)/)
{ chomp ($from = $1) ; }
}

$body = <STDIN> ;

print ("$mail_dir\t$from\t$subject\t$date\t", $body, "\n") ;

Note that the $body = line reads only a single line of the body. You'd have to read all the rest of the lines and filter them to handle tabs and newlines somehow, if you intend to output to tab-delimited format. If you'll use DB routines to go straight to a database, that wouldn't be a problem.



[ Reply to This | # ]
Also have to change mailbox1.pl
Authored by: wfolta on Sep 02, '02 03:40:43PM

Sorry for so many posts. Getting questions offline...

Need to supply the -k argument so mailbox2.pl gets the body:

cat '$full_dir' | formail -e -k -X Subject: ...



[ Reply to This | # ]