Perl批量下載Gmail附件的代碼

字號:


    這篇文章主要介紹了Perl批量下載Gmail附件的代碼,本文重點在使用Mail::POP3Client模塊和Gmail通信的方法,需要的朋友可以參考下。
    最近在寫一個從gmail批量下載附件的程序,用到了Mail::POP3Client和MIME::Parser2個模塊
    實現(xiàn)代碼:
    代碼如下:
    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();