A part of code:
# This part of code can receive a mail on STDIN and parse it
# This mail is composed of 3 parts:
# o) a body (text)
# o) an attached file (a picture in my case)
# o) specifications of the attached file (text, a short description in my case)
#
use strict;
use MIME::Base64;
use MIME::QuotedPrint;
my $boundary;
my $attachmentCount=0;
my $body='';
my $filename; # Attached file name
my $file; # Attached file content
my $specidifcations; # Attached specification
my $content_type_att_1; # Content type of part 1
my $content_type_att_2; # Content type of part 2
my $content_type_att_3; # Content type of part 3
while <STDIN> { # Read the mail from STDIN (you need to create a redirection
from email address to your script)
$mail.=$_;
if (($_=~m/^\\s*boundary=\"-+.+\"\\s*$/i) && (not defined $boundary)) { # To
get the boundary string (multipart/mixed MIME type)
($boundary)=($_=~m/^\\s*boundary=\"-+(.+)\"\\s*$/i);
next;
} elsif (($_=~m/^--multipart_boundary/i) && (not defined $boundary)) {
$boundary='Multipart_boundary';
} # Now, we have got the boundary string
if ((defined $boundary) && ($_=~m/^-+$boundary/i)) { # An attachment has been
reached
$attachmentCount++;
next;
}
if ($_=~m/charset/i) {
next;
}
if ($attachmentCount>0) { # The first \"attachment\" can be bypassed, it's
only the mail body
if (1==$attachmentCount) {
if ($_ ne '') {
if ($_=~m/Content-Transfer-Encoding/i) {
($content_type_attachment_1)=($_=~m/^Content-Transfer-Encoding:\\s(.*?)$/i);
}
if (($_!~m/^content/i) && ($_!~m/name/i) && ($_!~m/filename/i) &&
($_!~m/^\\s*$/)) {
$body.=$_;
}
}
} elsif (2==$attachmentCount) {
if ($_=~m/Content-Transfer-Encoding/i) {
($content_type_att_2)=($_=~m/^Content-Transfer-Encoding:\\s(.*?)$/i);
}
if ($_=~m/filename/i) {
($filename)=($_=~m/filename=\"(.*?)\"/i); # Filename of the attachment n�2
;-)
}
if ($_ ne '') {
if (($_!~m/^content/i) && ($_!~m/name/i) && ($_!~m/filename/i) &&
($_!~m/^\\s*$/)) {
$file.=$_; # Attached file content creation
}
}
} elsif (3==$attachmentCount) {
if ($_ ne '') {
if ($_=~m/Content-Transfer-Encoding/i) {
($content_type_att_3)=($_=~m/^Content-Transfer-Encoding:\\s(.*?)$/i);
}
if (($_!~m/^content/i) && ($_!~m/name/i) && ($_!~m/filename/i) && (trim($_)
ne '')) {
$specifications.=$_;
}
}
} else {
}
} else {
next;
}
}
# Decoding of part 1 (the body)
if ($content_type_att_1=~m/base64/i) {
$body=MIME::Base64::decode(trim($legend));
} elsif ($content_type_att_1=~m/quoted-printable/i) {
$body=decode_qp($legend);
}
# HAPPY PERL CODING ;-)
Use the MIME modules:MIME::Base64;MIME::QuotedPrint;Some other exist, but these
can decode a large range of mail. You need to parse the mail with your code,
but these modules allow you to decode the text + attachments.Do you need a
sample of code?OlivierI need a perl module that can help me get a attachement
from a massage, from a mailbox.Can you recomend me one?-- To unsubscribe,
e-mail: [EMAIL PROTECTED] additional commands, e-mail: [EMAIL PROTECTED]