in reply to Win32::OLE Outlook Error

Anyone know how to avoid this error?

Sure, satisfy the API and/or trap the error

... my $end = $folder->Items->Count; for my $ix ( reverse $end-5 .. $end ){ print "==========" x 7, "\n"; my $item = $folder->Items->Item( $ix ); for my $field ( @fields ){ ## my $val = eval { $item->{ $field } }; my $val; eval { $val = $item->{ $field }; 1 } or do { warn "uhoh $folder $ix $item $field : $@ "; next; }; print "$field: $val\n"; } } ... my $count = $obj->Folders->Count; for my $ix ( 1 .. $count ){ my $item = $obj->Folders->Item($i); return $item if $item->name eq $target }

Replies are listed 'Best First'.
Re^2: Win32::OLE Outlook Error
by cormanaz (Deacon) on Oct 09, 2014 at 13:25 UTC
    Thanks. I suppose I should have thought of that. The weird thing is that it has stopped happening with the original code, for reasons unknown :-/

    UPDATE: Well I spoke too soon. It is happening again, which is weird in itself, and suggests the cause is not an empty field. I don't understand the message about parameters, because the function call has the same number of parameters when I get the error and when I don't.

    Also eval does not trap the error -- it does so for the perl statement, but OLE still throws the error.