首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用perl从ms outlook下载附件

使用perl从ms outlook下载附件
EN

Stack Overflow用户
提问于 2014-02-21 15:00:32
回答 1查看 1.3K关注 0票数 1

我被分配使用perl从ms outlook下载附件,并将邮件主题作为Net file。由于我对perl并不熟悉,所以我很困惑如何继续工作。这是我必须继续执行的代码。

代码语言:javascript
运行
复制
use strict;
use warnings;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Outlook';
my $outlook;
eval {$outlook = Win32::OLE->GetActiveObject('Outlook.Application')};
die "Outlook not installed" if $@;
unless (defined $outlook) {
    $outlook = Win32::OLE->new('Outlook.Application','Quit') 
               or die "Unable to start Outlook";
}

$outlook->{visible} = 0;

my $dir = "F:\\OL\\";      #destination  directory
$dir =~ s/\//\\/g;

#get the Inbox folder
my $namespace = $outlook->GetNamespace("MAPI");

有谁能帮我处理代码的其余部分吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-21 15:39:32

您可以从以下信息中获得很多信息:Perl: Win32 32::OLE和Microsoft高效地遍历电子邮件附件id=700307

代码语言:javascript
运行
复制
use strict;
use warnings;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Outlook';
use Win32::OLE::Variant;

my $Folder = $NameSpace->GetDefaultFolder(olFolderInbox);

foreach my $msg (reverse in($Folder->{items}))
    print "Subject: ",$msg->{'Subject'},"\n";
    next if $msg->{'Subject'} !~ m!Net file!i;
    foreach my $atch (reverse in($msg->{Attachments}))
        if($atch->{FileName} =~ m/.xls$/i){
            if($atch->{FileName} =~ /Name of attachment1/i){
                print "found ".$atch->{FileName}."\n";
            }

       }
   }
}

或者你可以使用邮件::展望

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21937831

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档