in reply to loading files

You may try something like this (tested) example

#!/usr/bin/perl use strict; use warnings; use IO::File; use Mail::Internet; defined $ARGV[0] or die 'Usage: perl emailprogramma3.txt perltst\n'; my $file = $ARGV[0]; my $fh = new IO::File; # See File::Spec catpath method my $path = '/where/is/perltst/' . $file; $fh->open("< $file") or die "Can't open $file\n"; my $mail = Mail::Internet->new($fh); $mail->print_body; $fh->close; __END__ Output : ------ Content-Type: text/plain; name="Niet zelf een nummer bedenken!.txt" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="Niet zelf een nummer bedenken!.txt" SW4gZfafajkGAGEQRda789UIOKAJkljfqj8q8gdG9ldm9lZ2VuGAOGJHAFfagkl4538daj +a a3QgaGllcnZvb3IgQWRkSXRlbSBvZiBkZgBzdGFuZGFhcmQgcHJvZ3JhbW1hJ3MgdmFuIE +lC Qiag6FGIJ891rgahuClJCQQ== --------------000002060003020904090008--


hth,
PooLpi

'Ebry haffa hoe hab im tik a bush'. Jamaican proverb

Replies are listed 'Best First'.
Re^2: loading files
by Bass-Fighter (Beadle) on Dec 22, 2008 at 13:58 UTC
    alright, if I read this it could possibly work. what I only see is this: my $path = '/where/is/perltst/' . $file;
    does this mean that I every time I got an e-mail must change the path? that will be a lot of work at my working place.

      You haven't exactly been clear on what you actually want to achieve. Maybe File::Find or just glob or readdir (with opendir) will help you? All of these will return you a list of files in (or below) a directory. Maybe, if you want to process all the files in a directory, that's what you want?

      You can help us help you better by explaining what you want to achieve.

        what I want are the headers of an email logged in a txt file. the code where those stand are the email's themselfs. I want to put those emails in this program, get the headers: to, from, date, cc, subject and the filename of an possible attachment and print those in that txt file. but almost everything works already. the only thing that doesn't work is the loading of an email into my program in a way that it can be used first to get those headers and after that to get (if there are) the filenames of the attachments.