SamCG has asked for the wisdom of the Perl Monks concerning the following question:
PS: What the heck's with the 1-based collections in VBA, anyway? Must've taken me ten minutes to figure out how a zero subscript would be "out of range" ;)#! perl -w use strict; use Win32::OLE; my ($in, $to)=@ARGV; my $mail = new Win32::OLE('Outlook.Application'); my $ns = $mail->GetNamespace("MAPI"); my $inbox = $ns->GetDefaultFolder(6); ## the Inbox my $infolder = $inbox->Folders($in); my $tofolder = $inbox->Folders($to); my $count = $infolder->Items->Count; print "There are $count messages in the $in folder\n"; my $i=0; while($i <= $count){ #the original, which worked, but I didn't particularly care fo +r #the way the iteration was carried out #my $itm = $infolder->Items($i); ## the below line works (it returns a reference to something, +but... my $itms = $infolder->Items; for (@$itms){ ## for some reason $itms is not an array reference ## so. . . what is it? my $bdy = $_->Body; #the original line, which worked #my $bdy = $itm->Body; print "$bdy\n"; my $atm = $_->Attachments(1); #original line below #my $atm = $itm->Attachments(1); my $atmname = $atm->FileName; $_->Attachments(1)->SaveAsFile("H:\\erepts\\$i.$atmname"); $_->Move($tofolder); #below worked fine, saved to a folder on the network #$itm->Attachments(1)->SaveAsFile("H:\\erepts\\$i.$atmname"); #$itm->Move($tofolder); } $i++; } $mail->Quit();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Outlook and References
by NetWallah (Canon) on Nov 19, 2005 at 06:08 UTC | |
by SamCG (Hermit) on Nov 21, 2005 at 04:28 UTC | |
|
Re: Outlook and References
by davidrw (Prior) on Nov 19, 2005 at 03:07 UTC |