I am an intern and very new to this ...
My boss receives an email with two attachments every Monday, which he must turn into a wiki code and post it on our internal website. This process takes approximately 20 minutes every Monday due to the amount of information that needs to be transmitted. I was asked to convey this process.
I have code that will parse the file and break it down into components, and I have code to capture all attachments from its mailbox.
The problem I am facing is that my script starts with the oldest letter. This is not a big problem, but it leads to the fact that the script runs much longer than necessary.
use Cwd;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Outlook';
use Win32::OLE::Variant;
my $OL = Win32::OLE->GetActiveObject('Outlook.Application') || Win32::OLE->new('Outlook.Application', 'Quit');
my $NameSpace = $OL->GetNameSpace("MAPI");
my $Folder = $NameSpace->GetDefaultFolder(olFolderInbox);
my $dir = cwd . "\\";
$dir =~ s/\//\\/g;
my $atch1, $file1, $atch2, $file2;
print ref($Folder->{Items}) . "\n";
foreach my $msg (in $Folder->{Items}){
foreach my $atch (in $msg->{Attachments}){
if($atch->{FileName} =~ m/.xls$/i){
if($atch->{FileName} =~ /Name of attachment1/i){
$atch1 = $atch;
$file1 = $dir . "file1.xls";
}
if($atch->{FileName} =~ /Name of attachment2/i){
$atch2 = $atch;
$file2 = $dir . "file2.xls";
}
}
}
}
if($atch1 && $atch2){
print $file1 . "\n" . $file2 . "\n";
$atch1->SaveAsFile($file1);
$atch2->SaveAsFile($file2);
}
, , , , , ( ). .
, $Folder → {Items}. , . ref ($ Folder → {Items}, , Win32:: OLE, , Win32:: OLE, , , .
, ? ( $Folder → {Items}? - , Foreach? Dumping $folder → {Items} , ? , 2 ? ( , t , ))
.