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