>       my $date = $msg->{Datereceived};

I got it by:

my $date = $msg->{TimeReceived}->Date("yyyyMMdd");
I googled "MAPI" and got "DateReceived" first, is wrong.

By the way is there a good way to find the method I'm searching?
Here "Data::Dumper(\$msg)" will stop the running & displays nothing.

In Ruby "p  msg.methods" will display all the available methods.

Regards,
Hirosi Taguti
[EMAIL PROTECTED]

# Ruby is simple & fine, but I'm a genuine Perler!


> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Hirosi Taguti
> Sent: Wednesday, August 24, 2005 8:10 PM
> To: [email protected]
> Subject: Deleting old mails by MAPI
> 
> Hello,
> 
> I'm making a script to delete mails older than 1 month.
> But I cann't get date recieved.
> Someone knows the way?
> I can get Subject, text, can delete msg but cann't...
> 
> Regards,
> Hirosi Taguti
> [EMAIL PROTECTED]
> 
> #!/usr/bin/perl
> 
> use Win32::OLE;
> 
> print "COINIT_OLEINITIALIZE\n";
> Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE);
> die Win32::OLE->LastError(),"\n" if Win32::OLE->LastError();
> 
> print "session\n";
> # create a session object that will call Logoff when it is destroyed
> my $session = Win32::OLE->new('MAPI.Session','Logoff');
> die Win32::OLE->LastError(),"\n" if Win32::OLE->LastError();
> 
> print "Logon\n";
> my $err = $session->Logon('Outlook', "??????");
> if ($err) { die "Logon failed: $!"; }
> else      { print "OK\n"            }
> print "Logon OK\n";
> 
> print "get mail count\n";
> my $Count = $session->InBox->Messages->Count();
> print "\$Count =$Count\n";
> 
> my $Messages = $session->InBox->Messages;
> my $seq = 0;
> while (my $msg = $Messages->getNext) {
>       ++$seq;
>       my $sub = $msg->{Subject};
>       print "$seq: $sub\n";
> 
>       # delete older msg than 1 month
>       my $date = $msg->{Datereceived};
>       if ($date > 31) {
>               print "deleting $sub...\n";
>               my $rc = $msg->delete;
>               print "\$rc=$rc\n";
>       }
>       last if $seq > 5;
> }
> 
> print "End\n";
> __END__
> 
> _______________________________________________
> Perl-Win32-Users mailing list
> [email protected]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to