in reply to Win32::OLE Outlook help requested

Well, I could not find any way to extract the message headers, so the solution ended up being a variation on davis' idea about saving to a text file. Unfortunately, olTXT format does not contain the message header either, but the olMSG format does. This format is binary, but the message header is pretty much in tact, so I used the following to get the job done:
#!C:/perl/bin/perl use strict; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Outlook'; $|=1; $Win32::OLE::Warn = 3; my $Outlook = Win32::OLE->GetActiveObject('Outlook.Application') or Wi +n32::OLE->new('Outlook. +Application', 'Quit'); my $ol = Win32::OLE::Const->Load($Outlook); my $namespace = $Outlook->GetNameSpace("MAPI") or die "Can't open MAPI + namespace: $!"; my $Folder1 = $namespace->GetDefaultFolder(olFolderInbox); my $Folder2 = $Folder1->Folders("SPAM"); my $temp_file_name = 'D:\\exchange\\temp_spam.msg'; my @return_paths; foreach my $item (in $Folder2->{Items}){ unlink $temp_file_name if -f $temp_file_name; $item->saveAs( $temp_file_name, olMSG ); if ( -f $temp_file_name ) { my $previous_return_path = ''; open( SPAMFILE, $temp_file_name ) || die "Couldn't ope +n the $temp_file_name"; binmode( SPAMFILE ); while ( <SPAMFILE> ) { $_ =~ m/Return-Path: <(.*)>/; push ( @return_paths, $1 ) if $1 && $1 ne '' & +& $1 ne $previous_return_path; $previous_return_path = $1; } close( SPAMFILE ); } } my @deduped_return_paths = remove_duplicates( @return_paths ); my $deduped_return_paths = "deduped_return_paths.txt"; open( DEDUPEDSPAMFILE, ">>$deduped_return_paths" ) || die "Couldn't op +en the $deduped_return_paths"; foreach ( @deduped_return_paths ) { print DEDUPEDSPAMFILE "$_\n"; } close( DEDUPEDSPAMFILE ); exit 0; ####################### sub remove_duplicates { ####################### my @dirty_array = @_; my @clean_array = (); my %hash = (); foreach my $item ( @dirty_array ) { push @clean_array, $item unless $hash{$item}++; } return @clean_array; }
Thank you both for your help.

Update: Changed $|++ to $|=1.

bassplayer