为了账号安全,请及时绑定邮箱和手机立即绑定

如何从Gmail下载所有带有附件的电子邮件?

如何从Gmail下载所有带有附件的电子邮件?

GCT1015 2019-11-21 14:33:58
如何连接到Gmail并确定哪些邮件带有附件?然后,我想下载每个附件,并在处理邮件时打印出主题:和发件人:。
查看完整描述

3 回答

?
翻翻过去那场雪

TA贡献2065条经验 获得超13个赞

看看Mail :: Webmail :: Gmail:


获取附件


有两种获取附件的方法:


1->通过发送对由...返回的特定附件的引用 get_indv_email


# Creates an array of references to every attachment in your account

my $messages = $gmail->get_messages();

my @attachments;


foreach ( @{ $messages } ) {

    my $email = $gmail->get_indv_email( msg => $_ );

    if ( defined( $email->{ $_->{ 'id' } }->{ 'attachments' } ) ) {

        foreach ( @{ $email->{ $_->{ 'id' } }->{ 'attachments' } } ) {

            push( @attachments, $gmail->get_attachment( attachment => $_ ) );

            if ( $gmail->error() ) {

                print $gmail->error_msg();

            }

        }

    }

}

2->或通过发送附件ID和邮件ID


#retrieve specific attachment

my $msgid = 'F000000000';

my $attachid = '0.1';

my $attach_ref = $gmail->get_attachment( attid => $attachid, msgid => $msgid );

(返回对包含附件中数据的标量的引用。)


查看完整回答
反对 回复 2019-11-21
  • 3 回答
  • 0 关注
  • 2143 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信