Mime::Parser starter

2003-07-30 Thread awarsd
Hi,

i just need someone to guide me please
I'm retrieving from my host email(with attachment) using Net::Pop3
I print the message content- where we can see
Charsert ="iso-8869-1"
--- =_NextPart_001
to, subject
etc
now i see on the bottom of this message
Content-type: image/gif;
name = "image.gif";
content-trasfer-encodeing:base 64;
Content-disposition: attachment;
filename = "image.gif";

r01Gid1jhasdffsd897sdfa87dfas897asdfasdf  A LONG CODE

My question is that should i retrieve this 'LONG CODE' Save it in a file or
save the entire message content where it has subject content-type etc.?

thanx for any advice



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Mime::Parser starter

2003-07-30 Thread Stephen Gilbert


-Original Message-
From: awarsd [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 30, 2003 8:06 AM
To: [EMAIL PROTECTED]
Subject: Mime::Parser starter 


Hi,

i just need someone to guide me please
I'm retrieving from my host email(with attachment) using Net::Pop3
I print the message content- where we can see
Charsert ="iso-8869-1"
--- =_NextPart_001
to, subject
etc
now i see on the bottom of this message
Content-type: image/gif;
name = "image.gif";
content-trasfer-encodeing:base 64;
Content-disposition: attachment;
filename = "image.gif";

r01Gid1jhasdffsd897sdfa87dfas897asdfasdf  A LONG CODE

My question is that should i retrieve this 'LONG CODE' Save it in a file or
save the entire message content where it has subject content-type etc.?

thanx for any advice



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Hello,

you could, using Net::POP3 write the message out to a file and then using MIME::Parser 
parse each component such as:

$server = "mail_server";
$user = "account_name";
$pass = "password";
$pop = Net::Pop3->new($server) or die "Unable to connect to server $server: $!\n";
$pop->login($user, $pass) or die "unable to login with User: $user Pass; $pass $!\n";
@popstat = $pop-popstat();
if ($popstat[0] > 0) {
$msgs = pop->list;
foreach $msgid (keys %$msgs) {
open(CURRMSG, ">currmsg.msg") or die "Cannot open message: $!\n";
$pop->get($msgid, \*CURRMSG);
close CURRMSG;
$parser = new MIME::Parser;
$parser->extract_nested_messages(1);
$parser->parse_open("currmsg.msg") or die "Unable to parse message $msgid 
$!\n";
# do something with message/parts

# clean up
unlink("currmsg.msg") or die "Unable to delete temp message: $!\n");
$parser->filer->purge or die "Unable to delete message parts: $!\n";
} # Move to next message or end if none left
}

Please do your homework and verify this as I have type it mainly off the top of my 
head. Also, it's important to familiarize yourself with the documentation for 
MIME::Parser and Net::POP3. There are a bunch off things you should do in terms of 
error checking and other coding before this is a usefull program. Don't use this as 
is! Always remember that there is more than one way to do it! 

Steve

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Mime::Parser starter

2003-08-01 Thread Stephen Gilbert
MIME::Parser will parse out any file attacements also the message portion into 
separate files. If you wish to then view the files you can examine the dir it creates.

-Original Message-
From: awarsd [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 31, 2003 9:11 AM
To: [EMAIL PROTECTED]
Subject: Re: Mime::Parser starter


Hi,
Thank you for the code.
But one thing i really do not understand, is that i think mime::parser can
not decode an entire message in its pure format.
if I have the following from a message with an attachment
--=_NextPart_000_00E9_01C35775.1AE10310
Content-Type: image/gif;
name="bar.gif"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="bar.gif"
R0lGODlhHgAQAIcAgBAQiBMTjCYmmScolDo6pj9AoE1Ns1dYrHd5vWRkwsbJ5sPD/QAA












ACH5BP8ALAAeABAA
AAiBAAEIHEiwoMGDCBMqLBigocOHECNKbEigosWLGDNqrGigo8ePIEOK7IigpMmTKFOqLJmgpcuX
MGPKbLmgps2bOHPqrMmgp8+fQIMK7amgqNGjSJMqLXqgqdOnUKNKbVqgqtWrWLNqrTqgq9evYMOK
7SqgrNmzaNOqLbuwrdu3CgMCADs=
--=_NextPart_000_00E9_01C35775.1AE10310--

I just want to be able to display the attachment or recreate the attachment,
so I can download it or view it.
Maybe I should look at other modules than Mime, because I can easily get the
message with Net::POP3  with regex.
Any help to bring me on the correct paht is more than appreciated



-Original Message-
From: awarsd [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 30, 2003 8:06 AM
To: [EMAIL PROTECTED]
Subject: Mime::Parser starter


Hi,

i just need someone to guide me please
I'm retrieving from my host email(with attachment) using Net::Pop3
I print the message content- where we can see
Charsert ="iso-8869-1"
--- =_NextPart_001
to, subject
etc
now i see on the bottom of this message
Content-type: image/gif;
name = "image.gif";
content-trasfer-encodeing:base 64;
Content-disposition: attachment;
filename = "image.gif";

r01Gid1jhasdffsd897sdfa87dfas897asdfasdf  A LONG CODE

My question is that should i retrieve this 'LONG CODE' Save it in a file or
save the entire message content where it has subject content-type etc.?

thanx for any advice



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Hello,

you could, using Net::POP3 write the message out to a file and then using
MIME::Parser parse each component such as:

$server = "mail_server";
$user = "account_name";
$pass = "password";
$pop = Net::Pop3->new($server) or die "Unable to connect to server $server:
$!\n";
$pop->login($user, $pass) or die "unable to login with User: $user Pass;
$pass $!\n";
@popstat = $pop-popstat();
if ($popstat[0] > 0) {
$msgs = pop->list;
foreach $msgid (keys %$msgs) {
open(CURRMSG, ">currmsg.msg") or die "Cannot open message: $!\n";
$pop->get($msgid, \*CURRMSG);
close CURRMSG;
$parser = new MIME::Parser;
$parser->extract_nested_messages(1);
$parser->parse_open("currmsg.msg") or die "Unable to parse message
$msgid $!\n";
# do something with message/parts

# clean up
unlink("currmsg.msg") or die "Unable to delete temp message: $!\n");
$parser->filer->purge or die "Unable to delete message parts: $!\n";
} # Move to next message or end if none left
}

Please do your homework and verify this as I have type it mainly off the top
of my head. Also, it's important to familiarize yourself with the
documentation for MIME::Parser and Net::POP3. There are a bunch off things
you should do in terms of error checking and other coding before this is a
usefull program. Don't use this as is! Always remember that there is more
than one way to do it!

Steve



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]