X-cs: R
X-CS-Version: 1.0
From: bob  <[EMAIL PROTECTED]>
X-RS-ID: <Default>
X-RS-Flags: 0,0,1,1,0,0,0
X-RS-Sigset: -1
To: kevin
Subject: New ftp account created
Reply-to: [EMAIL PROTECTED]
MIME-Version: 1.0
Content-type: text/plain; charset=ISO-8859-1
Content-transfer-encoding: 8BIT
Date: Fri, 20 Jan 2006 14:33:28 -0000

The user cenlif00 has been added as an FTP user on mydomain.com

Host: ftp.mydomain.com
Username: cenlif00
Password: swe263

ftp://cenlif00:[EMAIL PROTECTED]

Hi,

I am trying something a little ambitions for me.

I have a file that, I think is in a binary format, containing emails. 
The file is from my email client, Pegasus, and I want to extract all 
the emails stored within the file and write them to separate files. 
There are no attachements in the email.

Below is what I have tried. If I look at the file in a text editor I 
see that all the mails are separated on ZX-cs: or X-cs: but as this 
is a binary file I am not sure it a srting intrepetation is going to 
work. At present I am not getting any text back from $eml.

There is some sample data below to. Can anyone give me some pointers.
Thanx.
Dp.


===========
use strict;
use warnings;
$/ = 'X-cs';
my $dir = 'C:/Documents and Settings/dpaikkos/Desktop/mail-folders/';

opendir(DIR,$dir) or die "Can't open dir $dir: $!\n";
my @files = grep{ /PMM/} readdir(DIR);

foreach my $f (@files) {
        print "File = $f is ";
        open my $FH, '<:raw',$f or die "Can't open $f:$!\n";
        my ($folder_name, $eml, $subject);
        while (<$FH>) {
                next unless /X-cs:\s/;
                $eml = $_;
                ($subject) = ($_ =~ /^Subject:(.*)/);
                print $subject,"\n";                                    # This 
works 
                $eml .= <$FH> until $eml =~ /^ZX-cs:/;
                
                my $neweml = $folder_name.'/'.$subject;  # The filename 4 the 
email
                print $eml,"\n";
                
        }
        close($FH);
}


================ Data ========

X-cs: R
X-CS-Version: 1.0
From: bob  <[EMAIL PROTECTED]>
X-RS-ID: <Default>
X-RS-Flags: 0,0,1,1,0,0,0
X-RS-Sigset: -1
To: joanna Saint-Mart <[EMAIL PROTECTED]>
Subject: New ftp account created
Reply-to: [EMAIL PROTECTED]
MIME-Version: 1.0
Content-type: text/plain; charset=ISO-8859-1
Content-transfer-encoding: 8BIT
Date: Fri, 20 Jan 2006 14:48:05 -0000
X-PMFLAGS: 34209920 0 0 7HB7PENI.CNR                        

The user rasmed00 has been added as an FTP user on mydomain.com

Host: ftp.mydomain.com
Username: rasmed00
Password: nam440


ftp://rasmed00:[EMAIL PROTECTED]
X-cs: R


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to