Greeting. I am trying to create a script that will search a user's outlook email and move any messages that mtahc a certain subject to a new folder. To accomplish this I found the Mail::Outlook module on CPAN that allows me to easily access the OLE Outlook calls via Win32::Ole.
My problem is this, the Mail::Outlook module does not have a specific method to move an email from one mailbox to another. I can display the email when my match occurs, but I cannot figure out how to move it. Here is an example of my code that works just find to pop-up an display any messages in my mailbox that match : use Mail::Outlook; use strict; # Open filehandle to Remedy report file open (_TICKETS,'C:\TicketCounts\MyOpen.rep') or die "Cannot open C:\TicketCounts\MyOpen.rep : $!"; # Iterate through each line of the file print "Obtaining list of open tickets from $remedyReportFile .... "; while (<_TICKETS>){ # Add ticket number to array in csv format push @myTickets, "$1" if m/CallT0000(\d+)/; } print " Ok.\n"; # Open an Outlook OLE connection print "Opening connection to Outlook .... "; my $outlook = new Mail::Outlook('') or die "Cannot create mail object\n"; # Change to the Support mail folder my $folder = $outlook->folder('Inbox/Support') or die "Cannot create folder object\n"; # Read the 1st message print " Ok.\n"; print "Searching messages for call ticket match .... " unless defined $bodyMatchString; print "Searching messages for subject containing: call ticket matches and body containing: $bodyMatchString ... " if defined $bodyMatchString; my $message = $folder->first(); # Iternate all messages in the folder while ($message) { # Strip the call ticket number out of the subject my $callTicketNumber=$1 if $message->Subject() =~ m/CallT0000(\d+) /; # If a call ticket number was found, compare against the user's open call tickets if (defined $callTicketNumber) { if ( (grep /$callTicketNumber/, @myTickets) ) { $emailMatches++; $message->Display; } } } Now, I want to change the $message->Display to a move operation. Searching the available OLE/COM Objects for Outlook via Microsoft's OLE/COM Viewer, I see that there is a move method for the mailItem CO class: [id(0x0000f034), helpcontext(0x004de8b9)] IDispatch* Move([in] MAPIFolder* DestFldr); I tried editing the Outlook::Mesage.pm file (that stores the message display call) to add a call to this OLE method. The 1st thing I did was to see if I could simply add a new su b to the PM file called moveMessage that in actually would simply display the messag the same way the display sub did: sub moveMessage { my ($self,%hash) = @_; # pre-populate the fields, if hash foreach my $field (@autosubs) { $self->{$field} = $hash{$field} if($hash{$field}); } # we need a basic message fields return 0 unless($self->{To} && $self->{Subject} && $self->{Body}); # Build the message $self->{message}->{To} = $self->{To}; $self->{message}->{Cc} = $self->{Cc} if($self->{Cc}); $self->{message}->{Bcc} = $self->{Bcc} if($self->{Bcc}); $self->{message}->{Subject} = $self->{Subject}; $self->{message}->{Body} = $self->{Body}; # Send the email $self->{message}->Display(); return 1; } I thought this would be an easy 1st step, but come to find out, I am getting teh following error when I run this: retrying default method at E:/Perl/site/lib/Win32/OLE/Lite.pm line 157, <_TICKETS> line 9. Win32::OLE(0.1403) error 0x8002000e: "Invalid number of parameters" in METHOD/PROPERTYGET "" at H:\outlook2.pl line 45 Now, I must confess that I am new to OLE and have limited exposure to Object Orientation. Can anyone point me in the right direction or show me some sample code that will move a message from one mailbox to another? I have searched extensively for any existing code to do this, but all I have found are very limited and do not come close to accomplishing my goal. I appreciate any help. Thanks! Jason -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>