eizo has asked for the wisdom of the Perl Monks concerning the following question:
foreach $msg_id (keys(%$Messages)) { my $MsgContent = $imap->get($msg_id); #my $Inhalt = $imap->get($msg_id); # print $Inhalt; PrintList(@$MsgContent); } sub PrintList { # Assign parameter to a local variable my (@lines) = @_; # Declare local variables my ($from, $line, $subject, $body); # Check each line in the header foreach $line (@lines) { if($line =~ m/^From: (.*)/) { # We found the "From" field, so let's # get what we need $from = $1; $from =~ s/"|<.*>//g; $from = substr($from, 0, 39); } elsif( $line =~ m/^Subject: (.*)/) { # We found the "Subject" field, so let's # get what we need $subject = $1; $subject = substr($subject, 0, 29); } elsif( $line =~ m/^Body: (.*)/ ) { $body = $1; $body = substr($body, 0, 29); #print $body; } # If we have parsed the "From" and "Subject" # field, then we don't need to keep on going. # Let's quit the loop here. last if( defined($subject) && defined($from) && defined($body) ); } # Print the result printf "From: %-40s Subject: %s\nInhalt: %s\n", $from, $subject, $bo +dy; }# end: PrintList()
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using Net::IMAP::Simple to read emails
by bgreenlee (Friar) on Dec 22, 2004 at 14:58 UTC | |
by Anonymous Monk on Dec 22, 2004 at 21:23 UTC | |
by bgreenlee (Friar) on Dec 22, 2004 at 23:25 UTC | |
by Anonymous Monk on Dec 23, 2004 at 01:49 UTC | |
|
Re: Using Net::IMAP::Simple to read emails
by sasikumar (Monk) on Dec 22, 2004 at 13:15 UTC | |
by eizo (Initiate) on Dec 22, 2004 at 13:29 UTC |