我被分配使用perl从ms outlook下载附件,并将邮件主题作为Net file。由于我对perl并不熟悉,所以我很困惑如何继续工作。这是我必须继续执行的代码。
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");有谁能帮我处理代码的其余部分吗?
发布于 2014-02-21 15:39:32
您可以从以下信息中获得很多信息:Perl: Win32 32::OLE和Microsoft高效地遍历电子邮件附件或id=700307
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";
}
}
}
}或者你可以使用邮件::展望
https://stackoverflow.com/questions/21937831
复制相似问题