Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Outlook email dates

by Anonymous Monk
on Sep 20, 2011 at 08:47 UTC ( [id://926864]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a script that can pull out all the emails from one of my outlook folders using Win32::OLE.

Retrieving the mail body an parsing it is trivial but I can't pull out the date the email was received.

Does anyone know if there is a method or attribute that contains the received date?

These are the objects I'm playing with - err working with.
my $outlook; eval {$outlook = Win32::OLE->GetActiveObject('Outlook.Application')}; die "Outlook not installed" if $@; unless (defined $outlook) { $outlook = Win32::OLE->new('Outlook.Application', sub {$_[0]->Quit;} +) or die "Cannot start Outlook"; } my $mailbox = seekFolder($outlook->Session, 'Mailbox - Mysurname, Myfi +rstname'); my $myfolder = seekFolder($mailbox, 'myfolder'); for (my $i = 1; $i <= $myfolder->Items->Count; $i++) { my $this_email = $myfolder->Items->Item($i); print "email text:" ,$this_email->Body, "\n:end text\n"; }


I've tried looking at some VBA scripts but haven't had any luck - though that may be due to VBA giving me headaches!

Replies are listed 'Best First'.
Re: Outlook email dates
by bingos (Vicar) on Sep 20, 2011 at 09:26 UTC

    A dig through the source of Mail::Outlook::Message shows that the MailItem attribute is called ReceivedTime which has further attributes of Date and Time

    print $this_email->ReceivedTime()->Date() . ' ' $this_email->ReceivedT +ime()->Time(), "\n";
      Thanks!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://926864]
Approved by Perlbotics
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-26 01:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found