in reply to Foreach-ing an OLE Collection object

The following worked fine for me, so I need to ask, what problems are you having?

use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Outlook'; $Win32::OLE::Warn = 2; # Throw Errors, I'll catch them my $OL = Win32::OLE->GetActiveObject('Outlook.Application') || Win32::OLE->new('Outlook.Application', 'Quit'); my $NameSpace = $OL->GetNameSpace("MAPI"); my $Folder = $NameSpace->GetDefaultFolder(olFolderInbox); foreach my $msg (in $Folder->{Items}){ foreach my $atch (in $msg->{Attachments}){ my $filename = "C:\\atchs\\" . $atch->{FileName}; $atch->SaveAsFile($filename); } }
C-.