Since your reply i complemented my code a little bit, found a few problems, searched a bit more and composed a solution based on other's code too.

So if this may help other newcomers i'm posting the code i've copy/pasted and built so far.

This program accepts a outlook .msg file as an argument and prints the readable text parts of the email i need

#!/usr/bin/perl -w use strict; use warnings; use Email::MIME; use Email::Address::XS; use Encode; use Email::Outlook::Message; for my $filename ( glob("$ARGV[0]*") ) { # will create an Email::Mime object from .msg file my $msg = new Email::Outlook::Message $filename or die "Can't ope +n $filename: $!\n"; my $msg_mime = $msg->to_email_mime; #print "Mime parts: " . $msg_mime->as_string, "\n"; my ($from) = Email::Address::XS->parse($msg_mime->header ('From')) +; my ($to) = Email::Address::XS->parse($msg_mime->header ('To')); my $subject = encode ("utf8", $msg_mime->header ('Subject')); my $date = $msg_mime->header ('Date'); print "FROM: ", $from, "\n"; print "TO: ", $to, "\n"; print "SUBJECT: ", $subject, "\n"; print "DATE: ", $date, "\n\n"; ## tell the filename reading # print 'Filename: ', $filename, "\n"; my (@mailData, $body); $msg_mime->walk_parts(sub { my ($part) = @_; # warn($part->content_type . ": " . $part->subparts); if (($part->content_type =~ /text\/plain; charset=\"?utf-8\" +?/i) && !@mailData) { @mailData = split( '\n', $part->body); } elsif (($part->content_type =~ /text\/plain; charset=\"?us-a +scii\"?/i) && !@mailData) { @mailData = split( '\n', $part->body); } elsif (($part->content_type =~ /text\/plain; charset=\"?wind +ows-1252\"?/i) && !@mailData) { @mailData = split( '\n', $part->body); } elsif (($part->content_type =~ /text\/plain; charset=\"?iso- +8859-1\"?/i) && !@mailData) { @mailData = split( '\n', $part->body); } }); #print $part->body; #only need utf-8 for this test foreach my $line (@mailData) { print encode ("utf8", $line) . "\n"; } }

In reply to Re^2: eMail processing for alarmistic by peteredhair
in thread eMail processing for alarmistic by peteredhair

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.