Perl批量下载Gmail附件的代码
最近在写一个从gmail批量下载附件的程序,用到了Mail::POP3Client和MIME::Parser2个模块
实现代码:
useMail::POP3Client;
useMIME::Parser;
my$U='User.Name@gmail.com';
my$P='uSeR.pAsSwORd';
my$X=newMIME::Parser;
$X->output_dir('C:\\download'); #directorytosaveattachment
my$G=Mail::POP3Client->new(
USER =>$U,
PASSWORD =>$P,
HOST =>'pop.gmail.com',
PORT =>995,
USESSL =>'true')ordie"Can'tConnectTheServer.\n";
for$i(1..$G->Count())
{
my$C=$G->HeadAndBody($i);
my$R=$X->parse_data($C);
}
$G->Close();